[Openmcl-devel] CLOS make-instance :around behaviour

Bob Hutchison hutch-lists at recursive.ca
Tue Oct 21 05:22:08 PDT 2008


On 20-Oct-08, at 10:21 AM, Bob Hutchison wrote:

> I wound up defining my own metaclass. Jan Marecek gave me a nice  
> head start, and Closer to Mop makes it portable (thanks again Pascal).

This is the head start that Jan provided:

On 19-Oct-08, at 5:24 PM, jan wrote:

>
> I've done this before, here is a sample:
>
>
> (defclass thing-class (standard-class) ())
>
> (defmethod closer-mop:validate-superclass ((class thing-class)
> 					   (superclass standard-class))
>  t)
>
> (defclass thing ()
>  ()
>  (:metaclass thing-class))
>
> (defmethod make-instance :around ((class thing-class)
>                                  &key &allow-other-keys)
>  (let ((thing (call-next-method)))
>    (or (find-thing thing) thing)))
>
>
> you can also use sb-mop:validate-superclass if you don't need
> portability and don't want to depend on closer.
>
> http://common-lisp.net/project/closer/closer-mop.html




More information about the Openmcl-devel mailing list