Late and way off the tangent, here I am!

At 11:22 PM 1/27/01 -0500, you wrote:
>I stumbled across something tonight that appears to me to be a rather
>another nasty paradigm shift that I have to make (or perhaps its a bug).
>
>I have reduced the problem and wrote this function to illustrate it (I
>named it lcDoesnt because it doesn'd do what I expect):
>
>lcDoesnt: func [ /local b ]
>[
>     b: [ 0 0 0 ]
>     print "The following line should ALWAYS be: 0 0 0 "
>     print b
>
>     b/3: b/3 + 1
>
>     print "The follwing line should ALWAYS be: 0 0 1 "
>     print b
>     print "......................."
>]
>
>My expectations are the following:
>
>(1)  the local variable "b" will be explicity set to [ 0 0 0 ]

I would expect the local variable "b" to be set to a location in memory.
You've initialized the contents of that location with 0 0 0

>(2)  the third element of "b" will be incremented by one, thus resulting in
>[ 0 0 1 ]

I would expect the same.

>(3)  because "b" is declared local, it should not be accessable outside of
>the function

It's not local scope, it's a local context, but it won't be visible in the
global context, no.

>(4)  "b" will be destroyed when the function exits

I don't expect that, because the current state of the block that is giving
value to lcDoesnt is stored in system/words.
b will be "destroyed" when the set-word lcDoesnt: is placed before a
different word or a different block
lcDoesnt: "b is gone"

>
>This pattern should repeat indefinitely as "b" is being explicity set
>within the function.  However, this is *not* the case.  Only item #3 holds.
>The problem is that "b" is somehow static, and so static, that even when
>the function explicitly *assigns* its value, that the explicit assignment
>is ignored in subsequent calls to the function (but not the first).


The set-word lcDoesnt takes the value of the function block it is adjacent to.
The function block has been modified, so lcDoesnt acts accordingly. 
Source lcDoesnt shows the modifications of the block.

>> lcDoesnt: func [ /local b ][
[        b: [ 0 0 0 ]
[         print "The following line should ALWAYS be: 0 0 0 "
[         print b
[
[         b/3: b/3 + 1
[
[        print "The follwing line should ALWAYS be: 0 0 1 "
[         print b
[         print "......................."
[    ]
>> lcDoesnt
The following line should ALWAYS be: 0 0 0
0 0 0
The follwing line should ALWAYS be: 0 0 1
0 0 1
.......................
>> source lcDoesnt
lcDoesnt: func [/local b][
    b: [0 0 1]
    print "The following line should ALWAYS be: 0 0 0 "
    print b
    b/3: b/3 + 1
    print "The follwing line should ALWAYS be: 0 0 1 "
    print b
    print "......................."
]
>> lcDoesnt
The following line should ALWAYS be: 0 0 0
0 0 1
The follwing line should ALWAYS be: 0 0 1
0 0 2
.......................
>> source lcDoesnt
lcDoesnt: func [/local b][
    b: [0 0 2]
    print "The following line should ALWAYS be: 0 0 0 "
    print b
    b/3: b/3 + 1
    print "The follwing line should ALWAYS be: 0 0 1 "
    print b
    print "......................."
]


>
>Any advice would be appreciated.
>

In my computer, there isn't "Code RAM" and "Data RAM", it's just all RAM,
and all of it is there for me to modify at my will.

>Thanks,
>Victor Mascari
>
>-- 
>To unsubscribe from this list, please send an email to
>[EMAIL PROTECTED] with "unsubscribe" in the 
>subject, without the quotes.
>
>

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to