empty arrays and cast(bool): WAT

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Feb 22 10:58:58 PST 2012


On Wed, Feb 22, 2012 at 01:13:24PM -0500, bearophile wrote:
> Regan Heath:
> 
> > I too am unsettled by the conflation of null and empty  
> > - and argued against it on several occasions, but hey, too late now I  
> > suspect.
> 
> It's not too much late.
[...]

I agree.

Conflating null and empty has been (one of) the source(s) of stupidities
like the === operator in Javascript and PHP. I mean, c'mon. Will the
next generation of languages start introducing the ==== operator now?

We already have .empty, why should the language go out of its way to let
you test an array with "if(array){...}"?  Code like that is hard to read
and fails to convey intent clearly.  "if (array.empty)" and "if (array
is null)" are much more self-documenting and less prone to
misinterpretation.


T

-- 
"How are you doing?" "Doing what?"


More information about the Digitalmars-d mailing list