Feature request: Path append operators for strings

Walter Bright newshound2 at digitalmars.com
Fri Jul 5 10:44:43 PDT 2013


On 7/5/2013 9:17 AM, H. S. Teoh wrote:
> Python uses +.

There's much historical precedence for + meaning concatenation, and much 
historical experience with the resulting ambiguity. The famous example is:

     "123" + 4

? In D, the canonical problem is:

     int[] array;

     array + 4

Does that mean append 4 to array, or add 4 to each element of array? What if you 
want to create a user defined type that supports both addition and concatenation?

Use + for addition, ~ for concatenation, and all these problems go away.


More information about the Digitalmars-d mailing list