Hi Gabrielle,

> The  reason  we  need them, is that words actually refer to values
> with an additional layer of indirection. A "double pointer" if you
> want  to  call  it  this  way.  Why?  Because  otherwise each word
> "instance"  would  have  a  different reference. Changing one word
> would not change all the other words with the same spelling.
>
> So we have something like:
>
>     some-word -----------\
>                           ()---------> value
>     some-word -----------/
>
>
>     some-other-word ----->()---------> value

I just would like to make sure that I understood it correctly. One could  
describe a simple example as follows:

[
   f: func [x] [print [x]]
   f 1  ; == 1
   x: 2
   b1: reduce [first second second :f]  ; == [x]
   print b1  ; == 1
]

- () is the indirection pointer Gabrielle used in his arrow sketch, which  
belongs to a certain word while running the script
- value is the right-most side he used

global context table:
()              | value
--------------------------------------------------
'f              | reference to 'f
'print  | reference to 'print
'first  | reference to 'first
'second | reference to 'second
'func   | reference to 'func
[]              | reference to function argument block
[]              | reference to function body block
[]              | reference to reduce block
'b1             | reference to reduce block
'x              | 2

function context table:
()              | value
----------------------------------------
'x              | unset! or later 1
[]              | block in function block

The left side with the words from Gabrielles sketch is either a second  
table with names which could be there more than once or just references in  
the Rebol internal structure when interpreting a block.

Could it look like that ?
[
   f-1: func-1 [x-1]-1 [print-1 [x-2]-1]-1
   f-2 1  ; == 1
   x-3: 2
   b1-1: reduce-1 [first-1 second-1 second-2 :f-3]-1  ; == [x-4]-1
   print-2 b1-2  ; == 1
]

The -X means always a reference to the according 'word in question in the  
context table. If I understood correctly that has to be like that as we  
have actually just data, so after one run of evaluation a block of data  
it's still just data and we need more versions of one word (this is what I  
understood as "instances" of a word). So Rebol musst keep internally some  
map of internal identifiers to names in the block. Like

word    -> context ()
----------------------------
f-1     -> 'f in global context
x-1     -> 'x in function context
x-2     -> 'x in function context
x-3     -> 'x in global context
x-4     -> 'x in function context
.
.
.

So if one updates or changes 'x in the function context x-1, x-2, x-4 will  
change too. But if I would bind x-2 into the global context then only the  
word -> context mapping table has to be modified. Maybe Ladislavs view is  
even easier, to think just of every instance as some kind of object which  
has an attached context field and a value field which is double  
referenced, thus referes to the () and then to the value (or just the ()  
field which is the context anyway).

The reason I'm so verbose is that I didn't see so much the need of the  
leftmost part with the "instances" of a word or wasn't sure what is  
exactly meant by instances of a word. But because we don't have code and a  
fixed scope for the variables we can't reduce it to just one word per  
scope and thus there have to be the many "instances" of one word.

I hope I don't annoy somebody with these lengthy post. But I have the  
feeling that this thread is/was very informative to me at least, stuff I  
hadn't figured out in detail so far. (unless now somebody tells .... ���hm  
yes, but .... ) :-)

regards

Michael




P.S.: I thought about just deleting the post, but maybe it's not that  
stupid (and obvious) after all.
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to