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


>Date: Thu, 22 Jun 89 10:19 PDT
>From: Gregor.pa@Xerox.COM
>To: David Alpern <Alpern@IBM.COM>
>    Date: Wed, 21 Jun 89 22:06:02 PDT
>    From: David Alpern <Alpern@IBM.COM>
>    (defun make-foo (&rest plist)
>      (apply #'pcl::*make-instance 'foo plist))
>    I would have though that would be what defconstruct would be great at,
>    but I can't figure out how to set it up so that the &rest arg (plist
>    above) is treated as a list of initialization arguments rather than
>    as just a single item.  To do this above, I needed to use apply --
>    but what can one do with defconstructor?
>It is best to go ahead and define such functions as you have done above
>with DEFUN and APPLY.  As you point out, DEFCONSTRUCTOR doesn't have a
>syntax for doing just this.

Actually, you can write a macro to create the appropriate constructor,
but you have to be very tricky in certain situations.  We wrote one,
which was a real hack, because we wanted to be able to make
DEFCONSTRUCTOR act exactly like the :CONSTRUCTOR option (that used be
available for the defclass definition).  In other words, if you had an
old kind of constructor, MAKE-FOO, it was just a "shorthand" for
(make-instance 'foo ....) and you could call it with any initargs that
you had specified.  We wanted this same behavior from DEFCONSTRUCTOR.

Since we always specify initargs for our slots, the constructors
created from defconstructor have to have ALL initargs as potential
keyword arguments.

Ignoring the issues that are involved in creating just such a
constructor and have it handle initargs and initforms correctly, am I
just on the wrong track altogether???? The constructors that result
are enormous!

Perhaps, the purpose of defconstructor was to have SPECIALIZED
constructors for classes.  In other words, when creating a FOO in
situation 1 use MAKE-FOO-IN-SIT-1 and when creating a FOO in situation
2 use MAKE-FOO-IN-SIT-2, where the different siutations require
different initargs, and the number of initargs used in a particular
situation is few.

Which is correct?

>DEFCONSTRUCTOR itself is going to go away soon anyways.  

What time frame are we talking about????