-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi!
Am 06.01.2011 13:56, schrieb Martin Simmons:
On Thu, 06 Jan 2011 10:33:43 +0100, Svante Carl v Erichsen said:
Am 06.01.2011 01:31, schrieb Scott L. Burson:
In section 7.1 it says: "The :initform for a shared slot may be used when defining or redefining the class."
I think that this is the most directly applying passage for this issue. I am not entirely sure about the exact intended meaning of "may be" and "used", but at first glance it seems to me that this means that both the "SBCL way" and the "ABCL way" do conform. Portable code thus should not rely on either behaviour; it seems that whether :initform forms of shared slots are evaluated during definition or during first instanciation is unspecified.
Your last sentence is definitely not true because the dictionary page for defclass says that the shared slot initform is evaluated in "the dynamic environment in which the defclass form was evaluated".
I think it should really start "The value of the :initform for a shared slot..." The point here is that the value is remembered and is "used" when needed.
The same page also says that the :initform form is evaluated every time it is used to initialize a slot. The question is when this initialization should take place for shared slots, not in which lexical and dynamic environment (that is clearly specified).
After rereading section 4.3.6 about how redefinition of classes works, I think that your interpretation of "may be" is correct. I guess that it would not make sense to specify that initforms of shared slots are evaluated during redefinition but not definition of a class. I wish section 4.3.2 was as explicit as 4.3.6.
To summarize: I now think that :initform forms of shared slots are specified to be evaluated during class definition.
Best wishes Svante