C++

Walter Bright newshound at digitalmars.com
Sat Jul 1 12:43:22 PDT 2006


Lucas Goss wrote:
> Also I did sort of agree with snk_kid on one point... I don't understand 
> why D uses "~" for adding words together instead of "+". It seems like 
> all the other languages I use all use + for adding words. Adding makes 
> sense for words...
> 
> I added on to what he said.
> I added some words to his sentence.
> If you add these two phrases together...
> 
> Is there any benefit to having a separate symbol for adding (ok, 
> concatenating)? If not feel free to break the language here too.

Concatenation is quite different from addition:

int[3] a = [1,2,3];
int[3] b = [4,5,6];

int[] c = a + b;	// c[] = [5,7,9]
int[] d = a ~ b;	// d[] = [1,2,3,4,5,6]

Two distinct operators are necessary.



More information about the Digitalmars-d mailing list