[Openmcl-devel] defstruct - generic constructor?
dlw at itasoftware.com
Wed Apr 29 20:56:19 UTC 2009
This behavior isn't specific to CCL; it's part of the definition
of Common Lisp. If you want to use make-instance, you
should use defclass instead of defstruct. (defstruct is an
earlier, more primitive facility that was added to Lisp
before object-oriented programming.)
David Reitter wrote:
> I've been trying to make instances of objects whose types have been
> defined using `defstruct'.
> Unfortunately, the obvious `make-instance' doesn't work (with ccl at
> least). I'm glad, however, that `class-of' and `class-name' do their
> The only way I got this to work was this clumsy hack:
> (apply (read-from-string (format nil "make-~a" (class-name chunk-type)))
> Is there a nicer, more efficient way of doing this?
> I'd need to find out what the constructor is for a given class.
> Reading the `defstruct' code didn't help me much.
> In more general terms, can I expect that `class-of' and `class-name'
> work for structures in other CL implementations?
> Thanks for your input.
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel