Subject: scoping and variables yet again

From: Kjetil Torgrim Homme <[email-masked]>
Date: Fri, 16 Sep 2005 14:30:21 +0200

I'm sorry, I don't think we have a clear consensus on this point yet.
so allow me to bring your attention to two suggestions for change in the
variables extension:

the text in -06:

        All variables have global scope: they are visible until
        processing stops.

this was deemed to be too risky security wise and allows too many feet
to be shot by accident when combined with "include".

before we discuss the wording, we should make sure we have consensus on
what the behaviour should be.

        a) an included script should not be allowed to change the
        variables in the parent script unless the parent script
        explicitly allows it.

        b) an included script should not be allowed to view the
        variables in the parent script unless the parent script
        explicitly allows it.

        c) the behaviour of a script should not change if it is included
        by a parent script rather than run standalone.

are everyone with me on this?

my suggestion is (text A), a complete reversal of behaviour:

    Variables are only visible to the currently running script.

the possibility of a different extension allowing a different scope is
implicit -- everything not forbidden can be overridden :-).  the usage
of the word "script" to mean a single fragment is consistent with other
Sieve documents.  e.g., an extension needs to be declared via "require"
in each script which uses it according to the base spec.

Aaron Stone's suggestion is similar in effect, I think (text B):

        All variables have global scope within a script. Future
        specifications may allow for a script to be composed of more
        than one file [part?], or for running more than one script per
        message [delivery?]. Such specifications may provide for
        different variable scoping rules.

it attempts to be more explicit, but I think it muddies more than it
clarifies, to be honest.

what is "global scope within a script"?  does this mean included scripts
are affected?  what is a "script"?  it may be unfortunate that we have
no established term for the collection of scripts into a bigger whole,
but as it is, I think "script" _is_ a single part (or file, or
fragment).

but before we discuss the wording, we should make sure we have consensus
on what the behaviour should be.

-- 
Kjetil T.

---

From: "Nigel Swinson" <[email-masked]>
Date: Fri, 16 Sep 2005 14:03:04 +0100

> are everyone with me on this?

+ d) a parent script should not be allowed to view the variables
    in the included script unless the included script explicitly allows it.

>    Variables are only visible to the currently running script.

Ok by me :o)

Nigel

---

From: Alexey Melnikov <[email-masked]>
Date: Mon, 26 Sep 2005 18:20:46 +0100

Kjetil Torgrim Homme wrote:

>are affected?  what is a "script"?
>
Ok, I see your point.

How about replacing the first sentence of B with your proposal A.

The rest of the paragraph is trying to say that there would be other 
specification with different scoping rules, or additional operators that 
can declare a variable global for other scripts/imported from another 
script.

>  it may be unfortunate that we have