[:] as empty associative array literal, plus warning for null
Regan Heath
regan at netmail.co.nz
Thu Jul 4 08:00:02 PDT 2013
On Thu, 04 Jul 2013 15:45:54 +0100, TommiT <tommitissari at hotmail.com>
wrote:
> On Thursday, 4 July 2013 at 13:32:25 UTC, Steven Schveighoffer wrote:
>> On Thu, 04 Jul 2013 08:52:12 -0400, Regan Heath wrote:
>>> Indeed. IMO if(arr) should mean if(arr.ptr) .. and I thought it did..
>>> or did this change at some point?
>>
>> No, it should mean if(arr.length). It means if(arr.ptr) now, and this
>> is incorrect. [..]
>
> The meaning of if(x) for all x of nullable types has always been if(x !=
> null) probably in all languages.
In fact, you can generalise further.
The meaning of if(x) is "compare the value of x with 0" (in C, C++, .. ).
The value of x for a pointer is the address to which it points.
The value of x for a class reference is the address of the class to which
it refers.
If D's arrays are reference types, then IMO they should exhibit the same
behaviour.
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list