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

Re: Some invariants

I like

(not (eq (make-instance x) (make-instance x)))

I believe that "make-" in general is expected to create a non-EQ
instance of a new object. The example you give (of looking up a name or
ID and either retrieving the old one or creating a new one should be
given a different name.

This is clearly a matter of preference (i.e., we don't have to restrict
make-instance for Classes to hang together), but the document we write
can and should impose stylistic conventions for what makes sense if the
user specializes built-in classes. 

That make-instance always creates new structure is a very useful
property; for example, it means that

(let ((x (make-instance 'foo)))
   (setf (foo-slot x) 3)

has no global side effects.