This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Trouble understanding define (!)
- To: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Subject: Re: Trouble understanding define (!)
- From: Michael Livshin <mlivshin at bigfoot dot com>
- Date: 01 Feb 2000 14:58:17 +0200
- Cc: Michael Livshin <mlivshin at bigfoot dot com>, Neil Jerram <neil at ossau dot uklinux dot net>, guile at sourceware dot cygnus dot com, djurfeldt at nada dot kth dot se
- Organization: who? me?
- References: <200001142054.UAA00622@ossau> <p2tzou4o5ov.fsf@pampelmuse.zrz.tu-berlin.de> <200001182250.WAA00624@ossau> <xy7ya9nezzz.fsf@mdj.nada.kth.se> <200001221200.MAA00478@ossau> <xy7bt6e82ru.fsf@mdj.nada.kth.se> <s3zotxrqoz.fsf@verisity.com> <xy7iu0cbc1z.fsf@mdj.nada.kth.se> <s3iu0bq1x5.fsf@verisity.com> <xy71z6z35os.fsf@mdj.nada.kth.se> <s33drfpm9d.fsf@verisity.com> <xy73drec8ap.fsf@mdj.nada.kth.se> <xy7oga1or3w.fsf@mdj.nada.kth.se>
Mikael Djurfeldt <mdj@mdj.nada.kth.se> writes:
> Two questions now:
>
> * Is this semantics too complex and obscure?
yes, IMHO.
here's my take on the situation, after I took an hour to think it
through.
1. we don't have to choose one or the other of two choices ("place
generics in their own global module" or "use usual module system
rules"). we can have both, and the decision as to where to place a
new generic is straightforward (see below).
2. an observation: generics are semantically closer to modules than
they are to functions -- they are modules that bind method
signatures to procedures. i.e. the names are lists of classes
(instead of symbols) and the lookup is by "cpl-closeness".
3. if the Kiczales's rule is enforced, there's no possibility of name
conflicts. example:
(define-method draw ((figure <circle>) (device <bitmap>))
...)
conceptually defines a procedure named `(<circle> <bitmap>)' in
module `draw'.
4. with the above in mind, we can conclude that we can safely have a
"magic module" that everyone imports called (generics). (note that
we will have one such "magic" module anyway, called (scheme),
though it's unmodifiable)
[ Mikael: what scalability problems do you have in mind? ]
now.
(define-method NAME SPEC ...)
- if NAME is bound, then it must be a generic, and we extend this
generic with the method
- if NAME is unbound, we execute (as if) (define-generic NAME), and
then extend it with the method.
(define-generic NAME ...)
- makes sure that we have a generic object bound to NAME in the
magic module (generics), and do nothing if it already exists. it
is an error to export NAME from the current module.
(define NAME (make-generic ...))
- use this if you want to have a non-global generic for whatever
reason.
metaobjectively yours,
--mike
--
I'm on a seafood diet -- I see food and I eat it. -- anonymous