Hello Brian,

Thanks for the brilliant and depthgoing explanation of contexts.

I must admit that I was wrong in implying that word lookup somehow happened hieracally 
at runtime.
Can we agree that word lookup is one-level (so to speak), but that you can still build 
heiracal (someone *please* spell this for me :-) contexts. Even though this is done at 
bind-time rather than evalution time?
I can see that this hierachy doesn't exist in a parent/child sort of way, but rather 
by binding the words in nested blocks multiple times (at each context creation).
This is only happens with litteral blocks.

Let's try:

Giving 'a a value in the global context
## a: 1
== 1
## blk: [a]
== [a]

the lit-word 'a in 'blk is now bound to the global context

## reduce blk
== [1]
## o1: make object! [a: 2 ba: blk]

the words 'a and 'ba is created in o1's context.
The lit-word 'blk is first bound to the global context, later evaluated to [a]
But this evaluation doesn't occur until the binding-fase is over and thus the 'a in 
[a] is still bound to the global context.

## o2: make object! [a: 2 ba: [a]]

In this case 'a in [a] is "found" at the time of binding (no evaluation is needed 
since it's a litteral block), and thus bound to o2's context (because 'a has allready 
been found in o2's context)

## reduce o1/ba
== [1]
## reduce o2/ba
== [2]

Seems to be true, please tell me if it's not.


Here's another funny thing that I've been playing around with:

(Fresh REBOL console)
## a: "global a"
== "global a"

'a now has a value in the global context

## proto: [a: 1 b: [a] c: bind/copy [a] 'self]
== [a: 1 b: [a] c: bind/copy [a] 'self]

the two a's in [] are now bound to the global context.

## print [reduce proto/4 reduce proto/7]
global a global a

making an object! based on the prototype

## obj1: make object! proto 

changing the prototype

## proto/2: 2
== [a: 2 b: [a] c: bind/copy [a] 'self]

making another object based on the modified prototype

## obj2: make object! proto

Examining the binding of [a] in the objects:
## reduce obj1/b
== [2]
## reduce obj2/b
== [2]

How did that happen, did obj/a change?

## print mold obj1

make object! [
    a: 1
    b: [a]
    c: [a]
]
## print mold obj2

make object! [
    a: 2
    b: [a]
    c: [a]
]

nope...

What about the binding of the 'a in 'c then

## reduce obj1/c
== [1]
## reduce obj2/c
== [2]

hmm.

Best regards
Thomas Jensen


Reply via email to