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: Dirk Herrmann
Subject: Re: guile-1.5.1 and deprecated ...
Date: Thu, 6 Sep 2001 20:03:53 +0200 (MEST)

On 06 Sep 2001 Marius Vollmer wrote:

> What about having syntax for marking a slot as either defining a new
> generic function, or using an existing one?  Like
>
>     (define-class foo ()
>       (slot-1 :init-value 1))
>
>     (define-class bar ()
>       (slot-1 :inherit #t :init-value 2)
>       (slot-2 :inherit #f))
>
> This would be roughly equivalent to
>
>     (define foo (make-class ...))
>     (define-generic slot-1)
>     (define-method (slot-1 (x foo))
>       (slot-ref x 'slot-1))
>
>     (define bar (make-class ...))
>     (define-method (slot-1 (x bar))
>       (slot-ref x slot-1))
>     (define-generic slot-2)
>     (define-method (slot-2 (x bar))
>       (slot-ref x slot-2))

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?  You better know anyway where your accessor functions come
from - if you don't provide them yourself.

Best regards
Dirk Herrmann




reply via email to

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