Operator overloading, structs

Yigal Chripun yigal100 at gmail.com
Fri Jun 5 05:27:37 PDT 2009


bearophile wrote:
> Yigal Chripun:
> 
>> what's more readable, my version or yours?
> 
> Mine, ihmo :-) Less things to remember. And the code is shorter and
> less noisy. Java programmers seems to
ignore how much noisy is their code.
> "empty collections are false" is easy. You don't have to write code
> like: > string s;
> if (s == null) ...
> if (s == "") ...
> if (s.length == 0) ...
> if (s.length) ...
> Or even:
> if (s is null) ...
> And few other variants I have seen in D code or snippets. Such things
> 
Do confuse d newbies (see digitalmars.D.learn).
> (If a collection is a class, and the object doesn't exists yet, and
the variable is just a null reference, then it's false anyway the
collection is empty still. Do you like this?).
> 
> 
>> is a bad pattern.<
> 
> Why?
> 
> 
>> it is even more problematic with floats.<
> 
> I think I have never had troubles from zero testing of
floats/double/reals in D.
> 
> If you want to try to convince other people (and I don't think D will
> 
change on this) you have to start listing some downsides of the current
design, some real bugs it leads to, and so on.
> 
> Bye,
> bearophile

for starters, null and empty are two distinct concepts and sometimes it 
is important to know the difference.
 > if (s is null) ...
 > if (s == "") ... // NOT same thing as above

also, with your version you need to remember _more_ things when reading 
code. I agree that the code is shorter but this is insignificant in this 
case.
Java code has nothing to do with this and this is NOT the reason why 
Java code can be noisy.



More information about the Digitalmars-d mailing list