Worst ideas/features in programming languages?
kdevel
kdevel at vogtner.de
Mon Nov 15 21:10:51 UTC 2021
On Monday, 15 November 2021 at 17:48:35 UTC, H. S. Teoh wrote:
[...]
> Why can't you just write:
>
> MyAbility ability;
>
> switch (ability) with(MyAbility)
> {
> case SOMETHING_1: break;
> case SOMETHING_2: break;
> case SOMETHING_3: break;
> case SOMETHING_4: break;
> case SOMETHING_5: break;
> }
>
> ? The `with` keyword was designed specifically for this
> purpose.
Nice. What about
import std.stdio;
enum SAB {
a = 1,
}
void main ()
{
with (SAB) if (a == 1) writeln ("true");
with (SAB) void foo () { writeln (a); } // no complaints!
foo(); // Error: undefined identifier `foo`
}
More information about the Digitalmars-d
mailing list