Rant after trying Rust a bit
Max Samukha via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jul 11 10:02:50 PDT 2016
On Thursday, 6 August 2015 at 06:54:45 UTC, Walter Bright wrote:
> On 8/3/2015 2:19 AM, Max Samukha wrote:
>> The point is that '+' for string concatenation is no more of
>> an 'idiot thing'
>> than '~'.
>
> Sure it is. What if you've got:
>
> T add(T)(T a, T b) { return a + b; }
>
> and some idiot overloaded + for T to be something other than
> addition?
That is a general problem with structural typing. Why not assume
that if a type defines 'length', it must be a range? Then call an
idiot everyone who defines it otherwise. I admit that special
treatment of '+' is justified by its long history, but 'idiot
thing' is obviously out of place.
BTW, it happens that '+' does not always have to be commutative:
https://en.wikipedia.org/wiki/Near-ring
https://en.wikipedia.org/wiki/Ordinal_arithmetic#Addition
More information about the Digitalmars-d
mailing list