On Wed, Aug 24, 2005, Cyrus Daboo <daboo(_at_)isamet(_dot_)com> said:
One other issue: how should include scripts interact with variables? Some
questions to illustrate this problem:
1) Should a variable defined in a 'parent' script be available in 'child'
(included) scripts?
2) Should a variable defined in a 'child' script be available in the
'parent' script after the point of inclusion? And if so, should those
variables be available to other 'child' scripts included after that point?
3) Should variables defined in a 'child' script only be local to that
script?
Comments?
According to the changelog in the ietf-variables-06 draft, a clarification
was made that variables do span includes. I could not find where this was
specified in the document, however. It sounds like the open issue is being
left to the include draft to resolve ;-)
I program most frequently in C and in PHP. I can't think how we might
apply any of C's scoping rules because curly braced scopes do not exist in
Sieve. Everything is global. This rather reminds me of PHP, actually.
Applying a PHP-ish model, each file would have a totally clean namespace.
If you wanted a variable to cross both namespaces, you would declare it
Global. In the ietf-variables-06 draft, section 4.1, gives a list of
modifiers. How about a :global modifier?
set :global "a";
# Now ${a} in this script points to the same memory as ${a} everywhere.
But... both set is defined like this:
Usage: set [MODIFIER] [COMPARATOR] <name: string> <value: string>
So how about this:
set :global "a" "${a}"
Or perhaps:
set :import "a" "${a_from_my_parent}"
set :export "a_back_to_parent" "${a}"
Aaron