Menu ▾ ▴

#10 namespace and generic function

General
open
General (24)
5
2001-06-23
2001-06-23
Shiro Kawai
No

The current mechanism of ensure-generic-function
may cause a problem if used with the module system.
Suppose there's two definitions:

(define-module foo
(define-class <foo> ...)
(define-method abracadabra ((self <foo>)) ...))

(define-module bar
(define-class <bar> ...)
(define-method abracadabra ((self <bar>)) ...))

If no generic method abracadabra is defined before
these definitions, there are two generic functions
created individually by ensure-generic-function.

It doesn't cause a problem until some other module
uses both foo and bar:

(define-module foobar
(use foo)
(use bar)

(define-class <foobar> (<bar> <foo>) ...)

(define-method abracadabra ((self <foobar>))
(next-method)))

Here, the foobar's abracadabra is combined with
bar's abracadabra generic function, for it is the
one bound to symbol "abracadabra" at the time of
the definition. So, next-method will not call
foo's abracadabra, even <foobar> inherits <foo>.

This is an inherent problem of using CLOS's
name-based method/gf combination.

Discussion


Log in to post a comment.