[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some invariants
- To: Moon@STONY-BROOK.SCRC.Symbolics.COM
- Subject: Re: Some invariants
- From: Masinter.pa@Xerox.COM
- Date: 7 Jan 87 18:16 PST
- Cc: Common-Lisp-Object-System@SAIL.STANFORD.EDU
- In-reply-to: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>'s message of Wed, 7 Jan 87 20:56 EST
I need to be more careful with my wording, since I clearly said it
wrong.
First, the issue here is not one of capability (what can you do) but of
style (what should you avoid doing).
Secondly, the phrase I used "has no global side effects" doesn't
describe what I meant, as David was quick to point out with a useful
example of global side effects when setting an accessor.
However, take the following program fragment:
(let ((x (make-instance 'foo))
(y (make-instance 'foo))
(setf (foo-slot x) 3)
(setf (foo-slot y) 4)
(foo-slot x))
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
expression.
Independent of the wording, do you agree with the sentiment?