On Feb 05, 2009 at 10:48, Henning Westerholt henning.westerholt@1und1.de wrote:
On Wednesday 04 February 2009, Daniel-Constantin Mierla wrote:
- 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