On Feb 05, 2009 at 10:48, Henning Westerholt
<henning.westerholt(a)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).
What if we decide what type of case value is by the first 'case'? If
first one is integer, then all should be integers and the 'switch' will
have integer optimizations. If not integer, then expect only strings or
regular expressions (which will be an useful addition) with the main
benefit of a nice-looking config file.
Cheers,
Daniel
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
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev