On Thursday, 14 February 2013 at 20:01:37 UTC, Jacob Carlborg wrote:
On 2013-02-14 13:42, Andrei Alexandrescu wrote:

I understand. Adding functions such as the negation of empty becomes a
judgment call.

Phobos does have quite a few simple functions that could be easily achieved through expression composition (e.g. trim) or statement composition (e.g. enforce). So again it's all a matter of judgment.

Walter and I don't consider the negation of empty as useful enough to
receive a name.

How about this, I have another similar function that might be useful in Phobos as well.

"isBlank" and "isPresent". "isPresent" is just the opposite of "isBlank".

"isBlank" works like this:

* If it's a string - it's considered blank if it's empty or only contains white space

* If you can call "empty" on it - return the result

* If it's a reference type and it's null - return true

* Otherwise return false

What does isBlank() return with tabs ?

I don't like having two functions doing the same thing, so isBlank() may be useful, isPresent() only adds cognitive overload and mere chaos to the code base (because someone is going to use both at the same time in the same function, making the code harder to understand).

Reply via email to