arrays: if(null == [ ])

deadalnix deadalnix at gmail.com
Mon May 14 12:30:25 PDT 2012


Le 14/05/2012 16:37, Steven Schveighoffer a écrit :
> Note that [] is a request to the runtime to build an empty array. The
> runtime detects this, and rather than consuming a heap allocation to
> build nothing, it simply returns a null-pointed array. This is 100% the
> right decision, and I don't think anyone would ever convince me (or
> Andrei or Walter) otherwise.
>

Obviously this is the right thing to do !

The question is why an array of length 0 isn't nulled ? It lead to 
confusing semantic here, and can keep alive memory that can't be accessed.


More information about the Digitalmars-d mailing list