On 2013-02-14 11:58:12 +0000, Jacob Carlborg <[email protected]> said:
On 2013-02-14 10:46, Walter Bright wrote:
I don't understand why one would go around the horn to just check for
!empty.
I've tried to explain, it shows what the intention is.
Instead of "str.length == 0" I use "str.empty". Instead of "!str.empty"
I like to use "str.any".
It's not a big deal but I would need to change quite a lot of code if
"str.any" isn't allowed.
I'd agree it's more readable, but it does not do what I expect when I
read it: to me 'any' sounds like an accessor that would take an item at
an unspecified position in a container (likely the less costly to get);
std.container defines 'removeAny' following that line. The correct name
would be 'hasAny'.
In this case I think it'd be much better if the language just
translated "if (str)" to something equivalent to "if (!str.empty)".
--
Michel Fortin
[email protected]
http://michelf.ca/