[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nested class definitions



There is a sense in which CommonLoops already addresses the problem of
nested class definitions.  CommonLoops is often presented in terms of
DEFMETH and DEFCLASS (or NDEFSTRUCT) but these are user convenient forms
of primitives which do not require classes and generic functions to have
names.  For example, one can write something like

(let ((c (make 'class ...)))
   (add-method some-discriminator (list c ...) ...)
   <body>)

where in the scope of <body> c is a local class.  Instances of it may be
returned and discrimination upon them works fine.   One issue here is
that an ideal implementation of CommonLoops should garbage collect a
class if the only references to them are from discriminators and super
classes.  The garbage collector should also remove the methods involved.

If this turns out to be a useful style one could package up the above in
some friendly macros.

----- ken