DIP 1015--Deprecation of Implicit Conversion of Int. & Char. Literals to bool--Formal Assement

Nicholas Wilson iamthewilsonator at hotmail.com
Wed Nov 14 04:38:41 UTC 2018


On Wednesday, 14 November 2018 at 04:33:23 UTC, Isaac S. wrote:
> On Wednesday, 14 November 2018 at 04:27:05 UTC, Walter Bright 
> wrote:
>> There have been various attempts over the years to "fix" 
>> various things in the D matching system by adding "just one 
>> more" match level. I've rejected all of them, because things 
>> that look simple and obvious with trivial examples tend to 
>> sink in a swamp with the dirty reality of the rather vast 
>> number of types and conversions that D supports. This happens 
>> in C++, and what people tend to do is just throw up their 
>> hands and hackishly add in more overloads until they get the 
>> result they want.
>
> The thing is, this isn't a new match level. Rather than the 
> enum implicitly casting to its literal (I'm hoping I'm using 
> the correct word here) I'm proposing it implicitly cast to its 
> typed literal (Instead of A.a implicitly converting to 0, it 
> converts to int(0)). This would mean it would match the int 
> since its a direct match.

The water is already somewhat murky here, the magic enums 
`__c_long` & friends already do some of this, but array of them 
don't (which I'm going to fix in 
https://github.com/dlang/dmd/pull/8950 as its needed to make 
__c_wchar_t actually useful). Extending this to all enums would 
probably do the trick.

> enum implicitly casting to its literal

memory type is what the compiler calls it.



More information about the Digitalmars-d-announce mailing list