arrays: if(null == [ ])

Regan Heath regan at netmail.co.nz
Thu May 17 05:10:32 PDT 2012


On Thu, 17 May 2012 00:08:49 +0100, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> On Wednesday, May 16, 2012 09:18:38 Steven Schveighoffer wrote:
>> but I still think we should discourage using null as a
>> sentinel, it leads to confusing code.
>
> If null were actually properly differentiated from empty, then this  
> wouldn't be
> a problem, but it's not. It _should_ be possible to treat null as a  
> sentinel.
> The fact that it causes issues is a major flaw in the language IMHO. But  
> given
> that flaw, it does very quickly become error-prone to use null as a  
> sentinel.
> In general, I'd say that the only reasonable place to do so is when  
> returning
> an array (and especially a string) from a function. The return value can  
> then
> be immeditely checked with is null before it has the chance to have  
> something
> happen to it which could cause it to be empty but non-null.

I want to re-re-re-register my dismay in the situation also.  For me it  
always comes back to.. I can do it with a pointer.. a pointer!  Why not an  
array?!?

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list