This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Any examples of modules using GOOPS?


I'd like to give another try at explaining how I thought when I
replaced #:init-form with #:init and #:init-thunk:

1. STklos doesn't have :initfunction.  (This is where my babbling
   about local-eval came from.  If you don't have :initfunction,
   you'll need to use local-eval somewhere beneath.)

   I missed the extra power of :initfunction (being able to use an
   arbitrary closure as initializer; the most obvious use being when
   the body is too large to fit nicely inside the class-definition).

2. I missed #:init.  I'd like to do things like

     (define-class <plot> (<curve>)
       ...
       (x-max #:init (* 2 pi))
       ...)

   and having the multiplication evaluated once instead of once per
   instantiation.

3. I thought that having three variants of initializers was overdoing
   it.

Therefore I decided to introduce #:init and :initfunction (giving it
the more explicit and correct name #:init-thunk) and skip :initform.

I don't think not having :initform is a big loss, since the cases
where you need to use :initform rather than #:init are few, and since
it's no big deal to write out the lambda explicitly in those few
cases.

In fact, I think it's a plus that the lambda is explicit.  I think it
makes the code more Schemey.

/mdj

(Of course you're right that :initform is Schemey in the more
 "absolute" sense.  :)