[Alexey Melnikov]:
In order to move imapflags extension forward I need support for
set/list variables.
I've read your draft, but I don't see why. I'm currently reading the
complete archive for this list to get a better feel for the philosophy
of Sieve, but it takes some time :-)
I haven't thought too much how this is going to be implemented (so
don't blame me if I say something stupid ;-)), but here are some
preliminary thoughts and questions:
1). Special syntax for list variables?
2). Can they be expanded inside strings? If yes, what does it mean?
3). Need new actions to add/remove values to the list:
addhead <listvariable> <value(s)>
addtail <listvariable> <value(s)>
remove <listvariable> <value(s)>
the first two operate on a list, but remove operates on a set.
it has occured to me that
SET "foo" ["hi", "there"];
seems a natural thing to write, which perhaps should be supported in
some way. I'm not sure what it should be used for, though.
if we want to go for generality, it may be a good idea to offer a
associative array/hash/dictionary rather than an indexed list. after
all, the hash can be used as if it was an indexed list, AWK does this.
SET "foo" :index "bar" "zot";
"${foo{bar}}" => "zot"
4). Need a way to convert a list variable to a string form
(conversion in other direction is easily achievable with existing
capabilities: set listvar ["${var1}", "${var2}", ...];)
New command:
asstring <identifier> <listvariable> <delimeter_str>
<delimeter_str> defines the delimiter that would be inserted
between values of the listvariable.
if the default delimiter is the empty string, the user can add
whatever delimiter he likes in the list. in AWK, there is a magic
global variable OFS, output field separator, to control this
behaviour.
in my current draft, a variable can only be expanded inside a string.
clearly, this expansion can not result in a list of strings. or can
it?
SET rcpt [ "Alice", "Bob" ];
"hello ${rcpt}, nice to see you" =>
[ "hello ", "Alice", "Bob", ", nice to see you" ]
just some quick thoughts.
--
Kjetil T.