What's missing from Phobos for Orbit (package manager)

Graham Fawcett fawcett at uwindsor.ca
Wed Mar 20 15:17:44 PDT 2013


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".

But "present" and "blank" aren't opposites in English. 
"isNonBlank" or "isNotBlank" are opposites of "isBlank", but 
"isPresent" would be the opposite of "isAbsent." It seems almost 
meaningless in the context of a string predicate --- If I saw it 
in code, I would guess it meant "not a null reference."

Similarly with "any" vs. "empty." I would think that "any" is 
synonymous with "some" and therefore should be the opposite of 
either "none" or "all" (leaning toward "all," given the 
commonality of some/all predicates in other languages, and the 
exists/forall concepts in predicate logic).

Regardless of their name, I would not like to see functions like 
these in Phobos. It's already challenging enough to keep the 
signature of the larger Phobos modules in one's head. Adding 
functions like these just adds noise... expressions like 
(!s.empty) are perfectly readable.

Graham


>
> "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



More information about the Digitalmars-d mailing list