Bug in function parameters type matching

EntangledQuanta via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 9 14:15:10 PDT 2017


On Saturday, 9 September 2017 at 21:08:16 UTC, Adam D. Ruppe 
wrote:
> On Saturday, 9 September 2017 at 20:45:59 UTC, EntangledQuanta 
> wrote:
>> unless enum's are implicitly castable to int's
>
> They are, unless you specify some other base type.
>
> https://dlang.org/spec/enum.html#named_enums
>
> See points 3 and 5 there. It will cast to the base type (int by 
> default), but you cannot pass the int as the enum.
>
>
>> which someone once told me that D didn't like implicit casts 
>> because of issues
>
> D has LOTS of implicit casts, including user-defined ones. Some 
> are restricted because of issues, but generally speaking, D is 
> pretty ok with them.

What's the point then of even having an enum parameter? If it 
will just be cast to an int, why not use an int? People always 
complain about making the compiler more complex but this makes it 
more complex without actually solving any problem or doing 
anything useful.

I guess those that actually write the code are the ones who get 
to decide where the arbitrary line is drawn, whatever is 
convenient for them. Would just be nice if they were up front 
about it instead of trying to justify with logic why they chose 
to prevent some things. I'd rather hear "I did it that way 
because I wanted to" rather than some blather trying to use 
logical reasoning.


More information about the Digitalmars-d mailing list