[:] as empty associative array literal, plus warning for null

TommiT tommitissari at hotmail.com
Fri Jul 5 03:52:07 PDT 2013


On Friday, 5 July 2013 at 10:39:38 UTC, Dmitry Olshansky wrote:
> 05-Jul-2013 13:24, Regan Heath пишет:
>> Given those statements I have come to the conclusion that if 
>> (x) on an
>> array should compare x.ptr to 0.
>
> I'd agree if arrays did decay to pointers or integers on demand 
> (implicit conversion).

Are you arguing that if(x) shouldn't even compile if x is a 
slice? If so, I was thinking the same thing. The fact that if(x) 
compiles makes sense only if you think of slice as a struct which 
happens to provide a convenience cast(bool) operator (which slice 
doesn't provide). The meaning of if(x) is obvious if x is a 
full/real/proper reference type. But since slice is just a 
half-reference, so the meaning of if(x) for slices is not 
obvious, and thus, it shouldn't compile.


More information about the Digitalmars-d mailing list