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]

GOOPS questions


Hello, all of you.

Recently I've started to use GOOPS, and it works quite fine (I also
switched from my old SGI to a Powerbook with LINUXPPC, and things work
much smoother now).  It is astonishing how much nicer things can be
formulated using OO style, and Guile is much more fun now.  Thanks to
all of you, especially to Mikael!

Nevertheless, I have some questions:

1) I have defined an object to administrate a list of data fields.  The
   basic class looks as follows:

(define-class <container> ()
  (sizes #:accessor my-sizes #:init-keyword #:sizes)
  (allocs #:accessor my-allocs #:init-keyword #:allocs))

I would like to have an initialization of this object which looks
like:

guile> (define x (make <container> #:sizes '(10 5)))
guile> (describe x)
#<<container> 3015c450> is an instance of class <container>
Slots are: 
     sizes = (10 5)
     allocs = (0 0)

That is, the allocs-field should be initialized with a value of
    (make-list (length sizes) 0)
where "sizes" has been initialized before.  Is there an easy way to
get this?  At the moment I use a constructor like:

(define (make-container sizes)
  (make <container>
	#:sizes sizes
	#:allocs (make-list (length sizes) 0)))

This works quite comfortably here, but there are other cases where it
doesn't.  Is there an alternative (perhaps with #:init-thunk)?

2) I studied Sonya E. Keene's book on CLOS, and I enjoyed it very
much.  [In contrast, I rather disliked reading Stroustrup's C++ book
(and have not really finished, yet).]  The question (to Mikael): how
much of CLOS do you intend to implement finally in GOOPS?  I had the
impression that CLOS is a very neat concept, and that everything is
quite useful.

3) And finally: why doesn't one use the simpler notation ":accessor",
... (as in CLOS) instead of "#:accessor", ...?

Yours,

Nico.

P.S.: My mail server in Heidelberg is blocked by ORBS and therefore
also by MAILER-DAEMON@sourceware.cygnus.com.  Please reply to
<Nicolas.Neuss@IWR.Uni-Heidelberg.De>.  I hope my sysadmins will fix the
problem soon.

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