[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Constructors
- To: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
- Subject: Re: Constructors
- From: Gregor.pa@Xerox.COM
- Date: Sat, 3 Oct 87 13:26 PDT
- Cc: Common-Lisp-Object-System@SAIL.STANFORD.EDU
- In-reply-to: <871002155644.5.MOON@EUPHRATES.SCRC.Symbolics.COM>
- Line-fold: no
Date: Fri, 2 Oct 87 15:56 EDT
From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
Look, it's very simple. If we're going to have a way to optimize out
the interpretive processing that a naive implementation of MAKE-INSTANCE
has to do, and generate specialized compiled code for making instances,
then we have to have some way to redo this optimization when something
changes. I claim it would be terrible for programmers to have to do
that by hand. I claim that constructors are a better way to keep track of
this automatically than any other way, because the special processing is
confined to a system generated function, and kept away from user written
functions. So what are the alternatives? We can decide that we don't
care about speeding up object creation that much, or someone can propose
a specific, coherent alternative.
I guess neither of us can figure out what the other is talking about here.
Maybe my previous paragraph makes this more clear: I hope so. If not, you
should respond with something very specific, such as an example showing
exactly what a programmer would write to get an efficient constructor.
Perhaps it should be something that has the same semantics as
(defclass class1 ()
((a :initarg :a)
(b :initarg :b)))
(defclass class2 (class1)
((c :initarg :c)
table)
(:default-initargs :b 1)
(:constructor make-2 (a &optional n b c)))
(defmethod initialize-instance :after ((x class2) &key (n 10))
(setf (slot-value x 'table) (make-array n)))
(make-2 "foo" 5)
I don't understand why make-2 has to be any faster at all than:
(defun make-3 (a &optional n b c)
(make-instance 'class2 :a a :n n :b b :c c))
And I still don't understand what other convenience is gotten from this
in the way of automatically fixing stuff if one of the defclasses
changes.
-------