DIPX: Enum Literals / Implicit Selector Expression

Walter Bright newshound2 at digitalmars.com
Fri Jul 1 18:32:17 UTC 2022


On 7/1/2022 8:42 AM, Steven Schveighoffer wrote:
> How I would design it:

Those are reasonable suggestions.

But just let me throw this out. I've heard from many sources that nobody 
understands C++ function overloading. It is described with pages of detail in 
the Standard. Even compiler writers only *temporarily* understand it while they 
are implementing it.

How C++ programmers deal with it is they randomly try things until it works.

D's overloading is simpler than C++'s. But it gets more complex all the time. 
For example, named arguments make it more complicated.

To add more complexity would take a really really strong benefit.

BTW, if you really want a specific case to work:

     enum A { a, b, c }
     alias a = A.a;
     alias b = A.b;
     alias c = A.c;

This could probably be automated with metaprogramming.


More information about the Digitalmars-d mailing list