[REBOL] Re: draw has no access to the current face
From: rotenca:telvia:it at: 1-Oct-2002 1:23
> Romano Paolo Tenca (BTW may I call you Romano for short? )
> Quoting Romano the with "magically binds the effect block words to the face
> objects words".
> I have some questions about this:
> Could someone tell me more about this "magic" with ? why is it no more
> needed in "user-data red"? why effect is now a set-word! ?
All the magic is relative to object and binding of words. When you define an
object starting from a previous object:
ob: make object! [a: 1]
make ob [a: 2]
you assign a new value (2) to the word 'a of the object: this can happen
because the word 'a in the block is bound to the word 'a in the object before
executing the block. The sequence of operations is:
1) duplicate object ob and its context
2) bind the block [a: 2] to the new context
3) evaluate the block [a: 2]
Now in 3) when you change the value of 'a in the block, you really change the
value of 'a in the object.
The point is that words are not variable, they have not a value, they are
alphanumeric pointers to context, which are "invisible" structure created by
make object! (not only).
The 'with word of Vid is a shortcut for something like this, only 'ob is the
style face and the block is the 'with block.
The 'effect word of Vid, instead, does not bind the block to the object
context, only assign the block to the effect field.
Effect [draw [pen user-data]] is like:
new-face: make face 
new-face/effect: [draw [pen user-data]]
with [effect: [draw [pen user-data]]] is like
new-face: make face [effect: [draw [pen user-data]]]
only in the latter case the block is bound to the face object before