Morale of a story: ~ is the right choice for concat operator

Nick Treleaven nick at geany.org
Sat May 26 11:04:44 UTC 2018


On Friday, 25 May 2018 at 08:27:30 UTC, Dukc wrote:
> If you add two characters, it interprets it as a concatenation 
> that results in a string with two charactes.
...
> Now, if I were programming in D, this would not have happened. 
> Using + always means an addition.

I don't think it makes sense to allow adding two characters - the 
second operand should be an integer type. Why have `byte` in the 
language if `char` works like an integer? Ideally ops like 
addition would allow one operand to be a character type, but 
require the other operand to be an integer - that is a useful 
operation, unlike adding '+' to 'Z'.


More information about the Digitalmars-d mailing list