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

Re: Some invariants



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?