Hi Ladislav,
you wrote:
>---------
>Of course, it works.
>But try to rewrite the code like this:
>
> sumnum: func [other [object!]] [ (do ! other get-num) +
> (do ! self get-num)
>
>and see what happens
>---------------
Do you realize that REBOL supplies every object automatically with the word
self? So if you are referring to the following construct:
root: make object! [
var: none
methods: make object! [
object: none
get-num: func [] [ object/var ]
sumnum: func [other [object!]] [ (do ! other get-num) +
(do ! self get-num)
]
then in your example self is referring to the embedded object methods.
Methods does not contain a word called var, therefore the attempt to
retrieve var from the methods object cannot work. Just as retrieving the
value of the word elephant from the object root cannot work. There is no
word elephant defined in the object root. There is not word var defined in
the object methods. self/var in the methods context however tries to look
up var in whatever self evaluates to at that point, which is the "methods"
object.
That's got nothing to do with re-entrancy! It's got nothing to do with the
way I implemented "!" .
Look at it like this:
If I have the simple object:
object: make object! [var: 1]
and I then try to use the path notation:
object/elephant
then REBOL will report an error (as it will in the case you describe above
and for the same reasons). To quote the error object/elephant will cause in
this example as proof that the path notation doesn't work would be foolish,
don't you think?
Again, filled with suspense, awaiting your response,
Elan