did rebol have a bigger problem leaking context?
Currently Rebol 2 and Red are little different in this regard.
useseems like a solution in search of a problem in red
An interesting way of looking at it. I've long found it a very tidy way of creating micro-contexts. With Rebol 3's tighter control on context, I've found it a useful way of tracking word use—even within modules.
P: context [ F: [ P1: [ name: "John" ] P2: [ name: "Mary" ] ] ] set [list1 list2] compose [ (words-of (Context (P/F))) (values-of (Context (P/F))) ] ; this works set [list1] compose [ (words-of (Context (P/F))) ] ; this doesn't work forall list1 [ probe list1/1 ] forall list2 [ probe list2/1 ]
P: context [ F: [ P1: [name: "John"] P2: [name: "Mary"] ] ] set [list1 list2] reduce [ words-of context p/f values-of context p/f ] forall list1 [probe list1/1] forall list2 [probe list2/1]
composeapplication and you'll probably figure out that it's not what you expected.
compose/onlyinstead, which composes nested blocks "as-is" (though
composeis superfluous here, as
reducecan do the same job just fine). Moreover, I don't get why you need multiple parenthesis nestings.
One of the great and terrible things about Redbol langs is their chameleon ability. @nedzadarek, a great many details are hidden under a facade that makes Red quickly accessible to people, but there is the risk that they will see it "as just like X", when it really isn't.
That has been just my problem. The original REBOL core manual did not a good job on letting me forget about variables, pointer and classic OOP.
@nedzadarek what you seem to call a "variable" is a binding + relation between symbol ID and value inside context.
What is SYMBOL ID ? I am getting confused. Could you make a graph adding real words, blocks and arrows to this structure and also underliyng C like rappresentation of the data structure ?
Word reference its context through a node (just a special intermediate structure) and has a symbol ID, which is an index in a symbol table. Context, in turn, is just a two-column table: first column is for
symbol! slots, second one is for
When a word is evaluated, a value is fetched in the context pointed by that word, from the value slot that correspond to the symbol ID held by the word. In that sense, words is an instance of an internal
symbol! datatype: word = a context reference + a symbol ID.
Symbol table, as I understand it, is nothing more than block of
symbol! cells, one per Red session currently (should be one per module in the future). Symbol ID is an index of a cell in that block.
symbol! cell holds a UTF-8 representation of a word (its "spelling", it's actually a pointer to a string buffer, again through node) and an alias field. If word is an alias of the other word (think case-insensitivity), this field will hold an index of the original word.
cell!: alias struct! [ header [integer!] ;-- cell's header flags data1 [integer!] ;-- placeholders to make a 128-bit cell data2 [integer!] data3 [integer!] ]