[Top] [All Lists]

Re: I-D ACTION:draft-daboo-sieve-include-03.txt (fwd)

2005-08-25 18:27:15

On Thu, 2005-08-25 at 23:58 +0000, Aaron Stone wrote:
Both... it's only a single sentence, and a major issue. I think a section
entitled "Scope" at around 4.2 or 4.1.4 would be best. Also, when the
issue comes up the user or implementor will have the question, "Why does
my variable contain weird values after an include?" or "Why can't I access
a variable set in another file?" and the answer should be explicit to
those questions.

I'm afraid I don't see how to expound on the sentence, since there _is_
only one scope from that draft's perspective.  the issue is better
discussed in the "include" draft.

Include will allow more sites to create libraries of common scripts. These
scripts will want to keep most of their namespace clean and/or protected.
Prefixed on the variables might work, but a :local / :global mechanism
would make these protections more explicit.

I'm not opposed to adding a ":local" modifier in the "include" draft.  I
can live with a no-op ":global", too, but I would prefer to not add
redundant elements.

suggested text:

4. Interaction with the "variables" extension

        Variables are by default globally scoped, and once set can be accessed 
until the
        script terminates.  This can lead to unintended name clashes, and to 
reduce that
        risk, this extension adds a modifier to the "set" action which is 
available to
        scripts requiring both the "variables" and "include" extensions.

4.1. Modifier ":local"

        A variable value set with the modifier ":local" will shadow the global 
value until
        the script returns.  This value is unchanged across "include" 
statements.  In
        contrast with other modifiers for "set", this modifier does not have 
any particular
        precedence and it does not change the resulting value.

                require "variables";
                set "var" "Hello Kitty";
                if address :localpart "From" "tweety" {
                        set :local "var" "Hello Birdie";
                        set "var" "Tweety says hello";
                # At this point, "${var}" can expand to either "Hello Kitty" or 
"Hello Birdie",
                # never "Tweety says hello".  A script which includes this 
snippet, will find
                # that "${var}" is either "Hello Kitty" or "Tweety says hello" 
after the
                # "include", unless it had executed a statement like
                #   set :local "var" "something"
                # prior to the include, in which case "${var}" will still be 

the implication here is that you must use :local everytime you set a
local variable.
Kjetil T.

<Prev in Thread] Current Thread [Next in Thread>