[Openmcl-devel] defstruct - generic constructor?
reitter at cmu.edu
Wed Apr 29 17:00:23 EDT 2009
Sorry, I should have made clear that I need a _generic_ constructor,
that is, a constructor for a type specified dynamically. (The `chunk-
type' variable in my example.)
On Apr 29, 2009, at 4:56 PM, Laughing Water wrote:
> Fortunately, the even more obvious solution works!
> Whenever you use defstruct, you're also getting a constructor. For
> (defstruct probe time temperature)
> (setf *my-probe* (make-probe))
> Others more advanced than me will give a more complete answer.
> Laughing Water
> On Apr 29, 2009, at 2:26 PM, 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-
>> 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