Howdy, Gabriele:
> make object! [
> set 'x make self [
> a: 1 b: 2
> ]
> c: 3 d: 4
> ]
> Being C and D duplicated in the "inner" object, using them as
> hidden variables may be tricky; surely that would make someone
> who's PROBEing the object to see how it works go crazy. :-)
There will only wind up one C and one D in either object.
The trick here is what does SELF evaluate to when you set 'x to it?
SELF at that time is an object, containing the words C and D, but
those words haven't yet been assigned anything at the time you assign
the word X to SELF. An object begins its creation by first collecting
all the words within the block that makes up its body, and adding them
into the new object context. The determination of what words are
included in an object's context precedes the evaluation of an object's
body. What's really happening above is we're taking a snapshot of an
incomplete object. So, moving the SET X later:
make object! [c: 3 d: 4 set 'x make self [a: 1 b: 2]]
..all the assignments happen before self is evaluated and no words
wind up being UNSET or END.
Everything is peachy about all this, but object words shouldn't
ever be END. They should be UNSET in these conditions-- A minor little
bug. ;)
Fun chatting with you about esoteric object stuff-- (-:
-jeff