Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Guile/Goops] Enforcing value restrictions in class c'tor

11 views
Skip to first unread message

alicetril...@gmail.com

unread,
Jul 28, 2021, 7:37:37 PM7/28/21
to
As an experiment to better understand GOOPS, I am currently writing a program in Guile using Guile-SDL2 and GOOPS, and as part of this I am implementing a simple wrapper class for RGBA values. I was looking to see if there was any way in GOOPS to enforce (via saturation) value boundaries of 0-255 for the individual color gradients. The simple wrapper class as I have it now is:
--------------------------------------------------------------------
(define-class <rgba-color>
(red #:accessor red-gradient
#:init-keyword #:r)
(green #:accessor green-gradient
#:init-keyword #:g)
(blue #:accessor blue-gradient
#:init-keyword #:b)
(alpha #:accessor alpha-gradient
#:init-keyword #:a))
--------------------------------------------------------------------

I know that this is a bit clumsy as it is, and I am not certain how useful this even will be, but I thought that it would make sense to wrap these values rather than dealing with the bare numerical values. I might switch to a simpler list or vector-based approach instead of a class if there's no straightforward way to enforce this pre-req in GOOPS.
0 new messages