Operator overloading, structs

bearophile bearophileHUGS at lycos.com
Thu Jun 4 13:38:52 PDT 2009


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



More information about the Digitalmars-d mailing list