Hi, Jeff, thanks for your examples, I didn't notice, that Self
could have any value, even unset!, as here:
object: make object! []
unset in object 'self
type? object/self
== unset!
That means, that objects can in principle represent any context.
If I understood correctly, the work of make "could" (with a big
simplification, of course) be described in Rebol like this:
make-object-sim: func [
initializer [block!]
/local words
] [
words: copy [self]
foreach item :initializer [
if set-word? :item [
append :words to word! :item
]
]
words: union :words []
use words [
bind words 'self
self: compose/deep [[(:words)]]
do bind/copy initializer 'self
:self
]
]
And, my question is as follows: wouldn't it be better (for the
sake of preventing some strange effects and to simplify things) to
change that to:
make-object-sim: func [
initializer [block!]
/local words result
] [
words: copy [self]
foreach item :initializer [
if set-word? :item [
append :words to word! :item
]
]
words: union :words []
use words [
bind words 'self
result: self: compose/deep [[(:words)]]
do bind/copy initializer 'self
:result
]
]
,which is more in a direction of representing any context (with
any Self value)
Regards
Ladislav
>
> That's essentially the way it works, Gabriele. :-) Yours is a
> better, simpler explanation than my was.
>
> One extra note, just to state the obvious: the set-word SELF
is
> first bound into the newly created object context making it
refer to
> THE SELF of the object before evaluating its assignment. The
stages
> of an objects creation are sometimes important. (-:
>
> -jeff
>
> > Hello [EMAIL PROTECTED]!
> > On 27-Mag-00, you wrote:
> > d>>> x: make object! [a: 1 b: 2 self: 3] d> == 3 d>>> type? x
d> ==
> > integer!
> > d> Mystery abounds,
> > Actually,
> > >> obj: make object! [a: 1 b: 2] >> obj/self: 3 == 3 >> probe
obj
> > make object! [ a: 1 b: 2 ]
> > I think it's just that MAKE OBJECT! returns the value of
SELF, so
> > if you modify it, you get the modified value as a result.
> > Regards, Gabriele.
> > -- Gabriele Santilli
>
>