This is the mail archive of the guile@cygnus.com mailing list for the guile project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
If I understand Michaels concern, the problem is this:
When adding a method to a generic function, the generic function is
destructively updated, so to speak.
So in the current implementation, when module B imports a generic from
module and adds a method, the generic function is changed not only in
module B but also in module A, which could be a surprise for users
of the function inside module A.
The safest approach to importing and updating a generic function would
then be something like this: in module B, define a *fresh* generic
function which then, each time it is invoked, will have to compute the
actual set of specializers by looking them up in both A and B in order
to derive the correct method to call.
Apart from the fact that this does not sound overly efficient, I am
not quite sure that this is really what one wants. If such a scheme
was implemented, it meant that there was no way for module B to
intentionally change the (global) behaviour of the generic function
originating from A.
An alternative to the restrictive approach of preventing B from doing
global updates, would be to allow it and instead use specifications on
the module A detailing what should and should be done to the generic
functions provided by A.
The idea is of course not my own. Kiczales and Lamping has written a
rather nice paper on how to specify OO libraries. It is called:
Issues in the Design and Specification of Class Libraries
and can be found under the name of documenting-oo-programs.ps.Z
somewhere at their ftp site, whose address I do not remember but which
I guess is the Xerox PARC one.
---------------------------+--------------------------------------------------
Christian Lynbech | Telebit Communications A/S
Fax: +45 8628 8186 | Fabrik 11, DK-8260 Viby J
Phone: +45 8628 8177 + 28 | email: chl@tbit.dk --- URL: http://www.telebit.dk
---------------------------+--------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
- petonic@hal.com (Michael A. Petonic)