Hi,

see the following:

a: "Global"
use [a] [
    a: "Local"
    b: [print a]
    c: "print a"
    do b
    do c
]

Result:
>> a: "Global"
== "Global"
>> use [a] [
[        a: "Local"
[        b: [print a]
[        c: "print a"
[        do b
[        do c
[    ]
Local
Global

I think, that this is what they meant.

Ladislav

> The new manual says:
>
>     Generally, the use of do for evaluating strings is not a
good
>     practice. It is much slower to process than evaluating
blocks,
>     and the context of words in a string is unknown.
>
> The first drawback ("much slower") is certainly understandable,
but
> the second ("context ... is unknown") is not clear to me.  Based
> on the experiment:
>
>     >> printa: "print a"
>     == "print a"
>     >> a: "global"
>     == "global"
>     >> do printa
>     global
>     >> f: func [/local a] [a: "local" do printa]
>     >> f
>     global
>     >> f2: func [/local a] [a: "local" do "print a"]
>     >> f2
>     global
>     >> f3: func [a] [do printa]
>     >> f3 "argument"
>     global
>     >> f4: func [a] [do "print a"]
>     >> f4 "argument"
>     global
>
> it would appear that the version I'm using (2.2.0.3.1)
consistently
> associates words done from a string with the global context.
>
> I'm familiar with language specifications that state that
something
> is "undefined", meaning something like the following:
>
>     We really don't want you to do this, even though the formal
>     syntax allows it -- it was just too much trouble to rewrite
>     the syntax to make it illegal.  So, if you do this, all bets
>     are off.  An implementation can do anything it pleases, and
>     can change behavior between versions, or even successive
>     executions of the same code.  You have now been officially
>     warned, so if you try it and get bitten, don't come whining
>     to us.
>
> Consequently, I'm not sure whether the phrase, "the context of
> words in a string is unknown", should be understood as:
>
> a)  formally "undefined", in the sense discussed above;
> b)  no firm policy decision had been made on the subject, so
>     the manual was intentionally left vague;
> c)  the author of the manual just didn't know;
> d)  the manual is simply wrong, and the statement should have
>     read "words appearing in a string will be bound to the
>     global context, which may not be what you expect.  This
>     may produce some very subtle bugs, which can frustrate you
>     to the point of requiring professional help." (;-); or
> e)  some other interpretation I need to have explained to me.
>
> Based on comments from Gabriele, Elan, and others regarding when
> contexts are created, I can certainly understand why
implementing
> option (d) might be easier than some of the alternatives.  If
> that's the case, why not just tell us?
>
> Any opinions, anyone?
>
> -jn-
>
>
>

Reply via email to