[Issue 6176] [tdpl] Cannot use string variables in case expressions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 17 19:48:06 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6176
--- Comment #15 from dawg at dawgfoto.de 2012-01-17 19:47:59 PST ---
Some argumentation in favor of a dynamic switch
----
switch (receive(ch0, ch1, ch2))
{
case ch0:
writeln(ch0.get());
break;
case ch1:
writeln(ch1.get());
break;
case ch2:
writeln(ch2.get());
break;
default:
// error
break;
}
----
auto token = nextToken();
switch (token)
{
case lastToken:
break;
case A: .. case B:
}
lastToken = token;
----
switch (str)
{
case re("[f|b]oo"):
case re("[f|b]ar"):
case re("[f|b]az"):
}
----
This can definitely become very confusing, e.g. when the
comparison has the side-effect of changing another case label.
To make it complete a dynamic case statement should be a boolean
expressions probably involving the expression being switch on,
i.e. the perfect dynamic switch is an "if-else" chain.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list