Worst ideas/features in programming languages?
Dr Machine Code
jckj33 at gmail.com
Sun Nov 14 18:41:10 UTC 2021
On Monday, 11 October 2021 at 18:27:29 UTC, russhy wrote:
[...]
>> Features you'd like to see in D
>
> - tagged union (built in, not as std/lib)
> - interface / signature for structs (built in, not as
> std/lib)
> - alternatively, reintroduce the * for classes
> - enum literals (being able to omit the enum name)
> ex:
> ```d
> enum MyEnum { A, B, C}
> MyEnum e = :A;
> my_function(:A);
> switch (e)
> {
> case :A: break;
> }
> // could be :, ., $, ! but that is not the point
> '''
This unscoped enums is one of the worst features in C/C++, imho.
I loved when I switch to languages that the enum got its scopre
but D you got both, you can also do:
```D
enum A = 0;
enum B = 1;
// ...
```
if you dislike to set their initial values manually, I think you
can write a template function to create enum values
More information about the Digitalmars-d
mailing list