[REBOL] Bug in 'use? Re:(8)
From: lmecir:geocities at: 23-Jul-2000 18:25
your Mental Model looks elaborated. The problem is, that it
doesn't describe the behaviour of Rebol 2.x correctly (no offense
meant). I could discuss it, but the problem is, that your Mental
Model's notions of "Context Table", "Value Bindings", "Currently
Active Context", "Effective Context Table" "Context Table Stack"
are not very useful for explaining the behaviour of Rebol Contexts
correctly. Instead of using your text and proving some errors, I
am writing a correct description of what is going on, which I find
more useful and less misleading for anyone watching the
> Hi Ladislav,
> thanks for your response.
> In the message you were responding to, I was commenting on your
> function example. Why then did your response include a
> function - your second example - that contains an embedded fun2
in a parent
> fun1? Both functions have an argument called x. Were you trying
> demonstrate that each of the two x's retain their respective
> is local to their respective functions? I was not disputing
> Certainly the two x's are bound in different contexts. The first
> fun1's context and the second 'x in fun2's context. Given that
each 'x is
> bound in a different context, and the context of both x's is
> appending them to the block blk, reduce [x x] returns the block
> demonstrating that each of the two x's retained their binding,
> therefore each 'x evaluates to the value it is associated with
by virtue of
> being bound bound in the context of the function it is
> Perhaps you felt it necessary to demonstrate non-recursive
> because you misunderstood me? To set the record straight:
> 1. Identical tokens that are bound in different contexts ('x
bound in fun1,
> 'x bound in fun2) retain their respective values.
> 2. I am not claiming that in recursive function calls those
words that are
> local to the function being called recursively are duplicated
> recursive call.
> You appear to comment on something I said:
> >As you pointed out, there is a conflict of two things:
> >"Static Context Binding" vs. "Dynamic Value Binding". As a
> >consequence, Use may misbehave during recursive calls.
> Interestingly you agree here with something I never said, nor
> say. Apparently you did misunderstand me. Maybe I did not
explain what I
> meant well enough.
> Since I am not sure where the misunderstanding begins, let me
> the basics. I'll present my "mental model" of contexts and
> behavior of recursive function calls within the context of my
> as I understand it.
> My understanding is that the two things that are bound in a
context are a
> word and a value. The relationship between them is loosely
referred to as a
> "binding". A "context" is simply the total of all currently
> effective bindings. The "Currently Active Context" is the
complete list of
> all word-value pairs that answer the two questions:
> 1. When I evaluate the following statement, which words are
> to values?
> 2. When I evaluate the following statement, what values are the
> bound words currently associated with?
> You can think of a context as a table consisting of two columns,
> column and a value column.
> Given the assignments:
> >> a: 1
> >> b: 2
> >> c: func [x y] [+ x y]
> The Currently Active Context Table would include the following
> word | value
> . | .
> . | .
> . | .
> a | 1
> b | 2
> c | func [x y] [+ x y]
> There exists a Context Table that is always effective, which is
> called the "Global Context Table". At times, there may be
> context tables effective, "Private Context Tables". The bindings
> "Private Context Tables" override the bindings defined in the
> Context Table
> >From the point of a statement that is being evaluated, there
> hierarchy of "Effective Context Tables". The lowest Context
Table in this
> hierarchy will first be used to search for the value of a word,
and if the
> word is not found in this context table, the search will
> context tables at higher levels in the context table hierarchy.
> table in the context table hierarchy is the context table that
> created, "last" in terms of previous statements that were
> When REBOL identifies a word in its input stream, it replaces
that word by
> the value that word is bound to (and in some instances evaluates
> value, i.e. functions, actions, primitives). In terms of our
, when REBOL evaluates a word, it looks up the value of
the word in