Deprecate case-variables
Paul Backus
snarwin at gmail.com
Tue May 16 18:45:46 UTC 2023
On Tuesday, 16 May 2023 at 17:31:58 UTC, Meta wrote:
>
> Aren't case variables useful for creating jump tables much more
> succinctly? It seems like that is a use case that should be
> carefully considered.
"Case variables" refers specifically to the use of a runtime
variable in a case label, like this:
int x = 1;
const int n = readln.strip.to!int;
switch (x)
{
case n: // <-- case variable
writeln("x == n");
break;
default:
writeln("x != n");
break;
}
Even if we remove case variables, the ability to specify multiple
values in a single case label will remain, as long as those
values are all compile-time constants. So this change would not
make it any harder to write succinct jump tables.
More information about the Digitalmars-d
mailing list