Forbid dynamic arrays in boolean evaluation contexts

bearophile bearophileHUGS at lycos.com
Mon Mar 25 07:58:29 PDT 2013


Andrea Fontana:

> Is empty() there just to match range "interface"?

Right, it's useful for arrays to fulfill the range protocol.


> length needs no import :)

On the other hand in a longhish module you sometimes need 
std.array for other purposes, so you have imported it already.

"data.empty" is shorter, and it contains only two (psychological) 
chunks, while "data.length == 0" contains four. So empty makes 
the code simpler.

And empty doesn't break the syntax uniformity of UFCS chains :-)

Bye,
bearophile


More information about the Digitalmars-d mailing list