guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile-1.5.1 and deprecated ...


From: Marius Vollmer
Subject: Re: guile-1.5.1 and deprecated ...
Date: 07 Sep 2001 03:04:34 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Dirk Herrmann <address@hidden> writes:

> Well, I have to admit that I don't quite understand what makes it
> inconvenient to require that a generic function is already defined before
> you add methods to it.  The examples above would currently have to be
> written as:
> 
>     (define-generic slot-1)
> 
>     (define-class foo ()
>       (slot-1 :getter slot-1 :init-value 1))
> 
>     (define-generic slot-2)
> 
>     (define-class bar ()
>       (slot-1 :getter slot-1 :init-value 2)
>       (slot-2 :getter slot-2))
> 
> This, however, doesn't seem inconvenient at all.  Or am I missing
> something?

No, it's me who was confused.  I forgot that you have to tell Goops
explicitely about accessor functions already.  I was actually thinking
about a `define-struct' macro that I'm using all the time which will
automatically insert slot options for accessors.

For example, 

    (define-struct assoc () comp formal value)

will expand into

    (begin
      (define-class assoc ()
        (comp #:accessor assoc-comp #:init-keyword #:comp)
        (formal #:accessor assoc-formal #:init-keyword #:formal)
        (value #:accessor assoc-value #:init-keyword #:value))
      (define (assoc? x) (is-a? x assoc))
      (export assoc assoc-comp assoc-formal assoc-value assoc?))

For such a macro, having to explicitely list all the generic functions
would be inconvenient, I'd say.  But the needed definitions can be
just as well be incorporated into the macro expansion.

Hmm.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]