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

Re: defconstructors

    Date: Thu, 22 Jun 89 17:32:26 EDT
    From: rich@linus.MITRE.ORG

    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!

My belief is that people should use the existing language features to
create these interfaces.  These features include DEFUN, MAKE-INSTANCE
and the very powerful (hairy) lambda-list keywords facility.  As an
example, take the following `constructor':

   (defun make-foo (x y)
     (make-instance 'foo :x x :y y))

It is then the job of the underlying CLOS implementation to optimize
these kinds of definitions.

DEFCONSTRUCTOR was a temporary hack designed to get around the fact that
PCL couldn't get from each Common Lisp the hooks it needed to "optimize
these kinds of definitions".  DEFCONSTRUCTOR was designed in such a way
that it would be as easy as possible for people to later go through and
convert all calls to DEFCONSTRUCTOR to calls to DEFUN and MAKE-INSTANCE.

Given this belief, it may be that I would say you are on the wrong track
by building such huge constructors.  Rather I would agree with the
following comment take from your message:

    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.

I would say this is exactly the kind of thing you can and should do with
named constructor functions created either with DEFCONSTRUCTOR or DEFUN

In her book Sonya Keene presents a good discussion of the kinds of
reasons why you want to have special constructor functions this way.

    What time frame are we talking about? (to delete DEFCONSTRUCTOR)

Little hard to say, it depends on how soon I get the right compiler
hooks, but I want to do it in the next few weeks.