[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
DEFSTRUCT copier query
Date: Mon, 3 Nov 1986 10:54 EST
From: Rob MacLachlan <RAM@C.CS.CMU.EDU>
Date: Monday, 3 November 1986 10:17-EST
From: <samalone at ATHENA.MIT.EDU>
Re: DEFSTRUCT copier query
(copy-bread (make-rye-bread :state 'stale :seeded-p nil))
A: #S(RYE-BREAD :STATE STALE :SEEDED-P NIL)
B: #S(BREAD :STATE STALE)
This unclarity has been pointed out before, but there didn't seem to
be any real consensus. I agree that it seems to be semantically
cleaner to return an object of the same type as the argument. I think
the only reasonable alternative would be to say that it is erronous.
Since there doesn't seem to be any support for B, no one can complain
if you implement A, although it may not be required for Common Lisp.
While we're at it, there are alot of problems with inheritance in
defstruct. Another is,
(defun (foo (:print-function (lambda ...)))
(defun (bar (:include foo)) slot1 slot2)
Now, does bar have a print function inherited from foo?
Clearly it can't inherit the constructor function from foo since
it doesn't have the same slots as foo, but the print function
is more at issue.
I think we should define :include to include only slots, and not any
other functions by options. If CommonLoops catches on, and if the
defstruct syntax is chosen, then we can specify the inheritance for
objects of class STRUCTURE to be only this, and you can use
a different class for inheriting other stuff.
Gold Hill Computers