"Robert L. Read" <[EMAIL PROTECTED]> writes:

> The contract is that make-instance should only be called once for a
> given object?

FWIW, I wrote a CLOS->SQL layer a few years ago, and I do agreed
with this assessment (that MAKE-INSTANCE should only get called once),
so my protocol ended up with these two extra methods:

(defgeneric customize-persistent-instance (instance &rest initargs &key 
&allow-other-keys)
  (:documentation "Used to customize an instance when it is created.  This takes
                   the place of the normal initialize-instance :after method.
                   This will be called both when the objects is being created
                   for the first time and being re-selected.
                   Subclasses should define :after methods as required.")
  (:method (instance &rest initargs &key &allow-other-keys) t))


(defgeneric customize-new-persistent-instance (instance &rest initargs &key 
&allow-other-keys)
  (:documentation "Used to customize an instance when it is newly
                   created by the application.  The object HAS
                   been commited to the database.")
  (:method (instance &rest initargs &key &allow-other-keys) t))


In my mind, when you get an instance via a SELECT, you're not
calling MAKE-INSTANCE, you're doing a hash table lookup to
find an object stored persistently in some imaginary infinitely
large lisp image.

YMMV, of course.

                                --ap
_______________________________________________
elephant-devel site list
elephant-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/elephant-devel

Reply via email to