Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Bug in 'use? Re:(8)

From: lmecir:geocities at: 23-Jul-2000 18:25

Hi Elan, 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 discussion. Next time. Ladislav
> Hi Ladislav, > > thanks for your response. > > In the message you were responding to, I was commenting on your
recursive
> function example. Why then did your response include a
*non*-recursive
> function - your second example - that contains an embedded fun2
in a parent
> fun1? Both functions have an argument called x. Were you trying
to
> demonstrate that each of the two x's retain their respective
binding, which
> is local to their respective functions? I was not disputing
that.
> Certainly the two x's are bound in different contexts. The first
'x in
> 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
extended by
> appending them to the block blk, reduce [x x] returns the block
[2 1],
> demonstrating that each of the two x's retained their binding,
and
> 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
associated with.
> Perhaps you felt it necessary to demonstrate non-recursive
function calls,
> 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
during the
> 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
intended to
> 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
start with
> the basics. I'll present my "mental model" of contexts and
discuss context
> behavior of recursive function calls within the context of my
mental model,
> 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
valid or
> 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
currently bound
> to values? > 2. When I evaluate the following statement, what values are the
currently
> bound words currently associated with? > > You can think of a context as a table consisting of two columns,
a word
> 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
new bindings:
> word | value > . | . > . | . > . | . > a | 1 > b | 2 > c | func [x y] [+ x y] > > There exists a Context Table that is always effective, which is
therefore
> called the "Global Context Table". At times, there may be
additional
> context tables effective, "Private Context Tables". The bindings
defined in
> "Private Context Tables" override the bindings defined in the
Global
> Context Table
.
> >From the point of a statement that is being evaluated, there
exists a
> 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
continue in
> context tables at higher levels in the context table hierarchy.
The lowest
> table in the context table hierarchy is the context table that
was last
> created, "last" in terms of previous statements that were
evaluated.
> 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
that
> value, i.e. functions, actions, primitives). In terms of our
Context
> Table
, when REBOL evaluates a word, it looks up the value of the word in