On 2/14/13 3:01 PM, 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

I think this is a fine candidate for a standard function. It does actual work, is useful, and can't be trivially achieved with inline code.

Andrei

Reply via email to