[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some invariants
- To: Common-Lisp-Object-System@SAIL.STANFORD.EDU
- Subject: Re: Some invariants
- From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Wed, 7 Jan 87 22:26 EST
- In-reply-to: <870107-181455-1005@Xerox>
Date: 7 Jan 87 18:16 PST
(let ((x (make-instance 'foo))
(y (make-instance 'foo))
(setf (foo-slot x) 3)
(setf (foo-slot y) 4)
It would be bad programming style for foo and its slot foo-slot to
behave in a way that this returned something other than 3 without
explicit documentation about this (fairly odd) behavior. Normally, one
would expect that each value returned by calls make-instance to be
independent of each other in this informal sense.
As long as this is a style recommendation rather than an implementation
requirement, expressing it as an "invariant" might be the wrong form of
Independent of the wording, do you agree with the sentiment?
I agree that a foo class that caused this program to return 4 would be
considered fairly odd and hard to understand. I certainly think it would
be wrong for the language to make it impossible to implement such a class;
I've had users plead with me that it was very important for them to be able
to do this (have make-instance do interning of one sort or another).
The style recommendation is fine, although it may be superfluous to put it
into the standards document.