empty arrays and cast(bool): WAT

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 18 20:02:20 PST 2012


On Sunday, February 19, 2012 04:56:13 Bernard Helyer wrote:
> On Sunday, 19 February 2012 at 03:33:14 UTC, Timon Gehr wrote:
> >> That would potentially break code.
> > 
> > It would also potentially fix code.
> 
> Well that's the stupidest thing I've read today. Can you point to
> people using it in the way that you expect? Besides which, that's
> just about the worst way to fix bugs in code is to change the
> language's behaviour.

I've seen pull requests for code where people have done

if(arr)

thinking that it would check for empty. The bizarrities with null == [] cause 
subtle problems all the time.

Now, whether more people have done

if(arr)

thinking that it checked null or more people have done it thinking that it 
checked empty, I don't know, but there's no question that some people do it 
thinking that it checks for empty.

- Jonathan M Davis


More information about the Digitalmars-d mailing list