[rust-dev] Proposal: rename sequence concatenation operator to ++
Marijn Haverbeke
marijnh at gmail.com
Wed Jan 25 11:46:20 PST 2012
Currently it is simply '+'.
The thing that prompted this is issue #1520 -- operator overloading.
Delegating + on non-builtin-numeric types to a `num` interface that
implements methods add/sub/mult/div/rem/neg methods seems elegant, and
similar to Haskell's approach. Vector-concatenation + messes
everything up though, since vectors can't meaningfully implement the
full num interface.
In general, it seems preferable to have operators mean a single thing.
The code in the compiler that handles + is often quite clumsy,
precisely because two very different things have to be dealt with.
I briefly floated the idea on IRC to just get rid of a concat binop
altogether, and use library calls for this, but it seems people like
their concatenating operator, so ++ seems a good choice (it has
something of a precedent in Haskells list append operator).
Those who oppose, start arguing.
More information about the Rust-dev
mailing list