This is the mail archive of the guile@sourceware.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: Some questions about GOOPS and CLOS in general


Mikael Djurfeldt <mdj@thalamus.nada.kth.se> writes:

> The following class definition:
> 
>   (define-class <c> ()
>     (x #:init-value 0)
>     y)
> 
> would allocate two slots in the instances of <c> and define the
> accessors x and y.
> 
> If x would be previously defined and y not, the macro above would
> expand to:
> 
>   (begin
>     (define x (ensure-accessor x 'x))
>     (define y (make-accessor 'y))
>     (define <c> (class () (x #:init-value 0) y #:name '<c>)))

Ah, I realize that I should clearify something here: It might look
like slots really have names here since I'm passing the symbols x and
y to the accessor constructors.

But note that these are only names of the *accessors* which really
only are generic functions.  `ensure-accessor' and `make-accessor'
above will re-use or create generic functions which still don't have
accessor methods for the class being defined.

They will be "populated" with accessor methods as a consequence of
using the `class' macro.  (make-instance calls initialize which calls
compute-accessors.)

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