When D is not nice

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Jul 6 19:51:54 PDT 2008


"Ary Borenszweig" <ary at esperanto.org.ar> wrote in message 
news:g4rsi1$2cnt$1 at digitalmars.com...
>
> How is it a pointless hole in the type system? I thought having "~" be the 
> concatenation operator instead of "+" was just to prevent that hole.

It's a bunch of special cases and a weakening of the type system in one area 
for no benefit that I can see short of a few saved keystrokes.  The 
semantics of the concatenation operator would have to be changed for string 
types (char[], wchar[], dchar[] -- and any permutation of const and 
invariant of those in D2), but not for any other array types, which is ugly. 
It also unnecessarily complicates the semantics and lookup rules for opCat, 
opCat_r, and opCatAssign for user-defined types.

>From an entirely cosmetic standpoint, I have a clear preference for:

format("x is {}, y is {}, z is {}", x, y, z)

vs.

"x is " ~ x ~ ", y is " ~ y ~ ", z is " ~ z

Concatenation also tends to make (unexperienced) people do stupid things 
like

writeln("x is " ~ x);

which creates a completely unnecessary string temporary, but they think that 
that's the only way to output a number.

I really cannot see any benefit from allowing concatenation of strings and 
non-strings (and non-characters). 





More information about the Digitalmars-d mailing list