[SR-Dev] git:andrei/switch: script parsing: C style switch() & case support
Andrei Pelinescu-Onciul
andrei at iptel.org
Thu Feb 5 16:52:54 CET 2009
On Feb 05, 2009 at 10:48, Henning Westerholt <henning.westerholt at 1und1.de> wrote:
> On Wednesday 04 February 2009, Daniel-Constantin Mierla wrote:
> > 2) it can shorten the script and save some ifs:
> >
> > switch(a) {
> > case v1:
> > something;
> > case v2:
> > something else;
> > break;
> > }
>
> Hi all,
>
> this is also a big advantage for me, as if your script gets too long its much
> harder to debug and understand.
>
> > It could be a sswitch (although I would prefer single name to avoid
> > confusions) if breaks logic for integer optimizations.
>
> Having two different switch statements is IMHO really confusing.
It's like the operators: we either have different switch() for strings
and integers or we have typed variables. Without this restrictions one
cannot optimize (IMO we should have both since that would allow for
much better type checking at startup -> a lot of possible script errors
can be easily indentified => more user friendly).
How about using match() for sswitch()?
Also should we use only strings or REs too, e.g.:
match($v){
case "foo":
case /[0-9]+/:
...
}
Andrei
More information about the sr-dev
mailing list