guile-user
[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: 06 Sep 2001 01:49:17 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Michael Livshin <address@hidden> writes:

> Dirk Herrmann <address@hidden> writes:
> 
> > What are the reasons for keeping such a strange behaviour?
> [...]
> * it's especially convenient for accessors (which are generics).
>   without it class definitions would be much more verbose (and
>   quite annoying to write).

Yep, that's the sticky point.  Using generic functions for slot
accessors is very powerful, and we need to make this convenient.

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))

The `:inherit #t' slot option would make the accessor use an existing
generic function, and `:inherit #f' would define a new one.  `:inherit
#f' would be the default.


This leaves the problem of detecting un-wanted redefinitions.  This is
not unique to generic function, however.  We could have a global flag
that makes `define' issue warnings for redefinitions.  That flag would
be set during `load', but not for code executed directly from the
repl.  I'm not sure whether we can make redefinitions signal errors,
but it feels like a good idea to me, as long as we don't interfere
with interactive development.



reply via email to

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