This is the mail archive of the
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: Marius Vollmer <mvo at zagadka dot ping dot de>
- Date: 01 Feb 2000 21:02:56 +0100
- 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
- References: <200001142054.UAA00622@ossau> <email@example.com> <200001182250.WAA00624@ossau> <firstname.lastname@example.org> <200001221200.MAA00478@ossau> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
Mikael Djurfeldt <email@example.com> writes:
> Two questions now:
> * Is this semantics too complex and obscure?
I don't think generics should be handled any special by the module
system. The semantics of generic functions and the semantic of the
module system should be completely independent. In the defining
description of generic functions, there should be no reference to the
module system; and likeweise, there should be no reference to generic
functions in the defining description of the module system.
`(define-generic foo ...)' should be conceptually an abbreviation for
`(define foo (make-generic ...))' and all the module system
interaction is derived from the behaviour of `define'.
`define-method' is more complicated because it behaves differently
depending on whether a generic function already exists or not. In my
view, it would be acceptable to just demand that the generic function
already exists before adding methods to it. [This might pose problems
for the generic functions that are slot accessors, hmmm...]
Generic functions shuld be regarded as first class objects that might
get bound to variables (or not). The names of these variables are
handled by the module system, but independently of the type of object
that they refer to. After all, a variable might hold different kind
of objects in their lifetime. It might start out as `#f' and later
point to a `ordinary' function, and finally to a generic function.
Treating generic functions specially is a step away from dynamic
typing, which I would consider to be a step in the wrong direction.
I think it is useful to sometimes clearly distinguish between
`compile-time' and `run-time' concepts. Modules, macros, and
variables with their names are on the compile-time side; classes,
procedures and generic functions with their methods are on the
[ One _could_ hoist classes and generic function to the compile-time
side, like C++ does, but I hope that the mere mention of C++ is
enough to dispute this choice. ]
Of course, this distinction depends on the viewpoint, and the
compile-time things should be reflected back into the run-time, so
that there is run-time access to the compiler, the module system, etc,
but one should be aware that one is now one level above the code one
is compiling, or the objects that are given names by the module
system. Just like one needs to be aware of the differences between
the code that computes macro expansions, and the code that they expand
> * How do we combine this with separate compilation of modules?
> (This is an interesting question also with regard to the current
Ideally, the compiler should not need to know about generic functions.
It might make good use of such knowledge for optimizations, but it
should not be nneded to have a correct compiler.
That's my take on this stuff, anyway.