Thoughts on some code breakage with 2.074

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu May 11 05:26:11 PDT 2017


On 5/11/17 5:37 AM, deadalnix wrote:
> On Wednesday, 10 May 2017 at 19:06:40 UTC, Ali Çehreli wrote:
>> Bummer for H. S. Teoh I guess... :/
>>
>> Although I prefer explicit over implicit in most cases, I've never
>> graduated from if(p) and still using it happily. :)
>>
>> Ali
>
> All bool conversions in D are value based, not identity based. Not only
> this is error prone, this is inconsistent.

What does "value based" and "identity based" mean?

bool conversions vary widely and allow a lot of flexibility (at least 
for structs):

if(arr) -> same as if(arr.ptr)
if(someInt) -> same as if(someInt != 0)
if(someObject) -> if(someObject !is null && someObject.invariant)
if(someStruct) -> if(someStruct.opCast!(bool))

-Steve


More information about the Digitalmars-d mailing list