See below:
Russell [EMAIL PROTECTED]
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 16, 1999 6:17 AM
Subject: [REBOL] "logical" value referencing ... Re:(5)


> On 12/16/1999 at 12:17 AM [EMAIL PROTECTED] wrote:
> [...]
> > On the other hand, I prefer to keep the vocabulary needed to describe
> > REBOL
> > to a minimum. I also like to exploit the similarity of principles, to
> > keep
> > the volume of information needed to reason about REBOL to a minimum. If
> > we
> > just stick with the idea that the current position of a series is
> > local,
> > whereas the data storage is global, we can consider a series to be
> > something similar to a function. The idea of global and local values,
> > persistent changes and temporary changes arises in the same manner,
> > when we
> > discuss the behavior of functions:
> >
> > For instance, we always warn newbies that each time the following
> > function
> > is called, digits will be added to a string referenced by a local word,
> > unless make string! or copy "" are used to guarantee a fresh string
> > each
> > time the function is evaluated:
> >
> > >> f: func [/local a] [ a: "" for i 1 6 1 [insert tail a i] print a]
> > >> f
> > 123456
> > >> f
> > 123456123456
> > >> f
> > 123456123456123456

But look at this snippet of console stuff!

>> a: "" b: copy "" append a 1 append b 1 append a 2 append b 2 print a
print b
12
12
>> a: "" b: copy "" append a 1 append b 1 append a 2 append b 2 print a
print b
12
12
>> a: "" b: copy "" append a 1 append b 1 append a 2 append b 2 print a
print b
12
12
>>

Looks like something is different inside the block of the 'for - almost as
though the 'a inside the block is somehow different from the a in the
fragment a: '', maybe the a in the 'for block refers to a global entity
versus that referred to by the local 'a in a: "".  This rings a bell with
me - I think I've encountered this before.  Actually, making a variable like
'a local merely means it wont screw up an external variable of the same
name, and also, outside the function the local variable 'a will not have the
value it last had inside the function.  But a manipulating a local variable
inside a 'for function CAN set up a global "entity" that can be referenced
by the same word, 'a, in following executions of the  'for function.
Probably I haven't expressed this precisely, but I've encountered the
"problem" before and had to use 'copy to avoid it.
> >
> > The word 'a is local, but the string it references, like all literal
> > values, is global. I like the idea that you can think of a series as
> > somewhat analogus to a function. The data-storage is global, whereas
> > current position is local.
> [...]

Reply via email to