Implement Add for String + String

To be very exact, strings form a well-defined mathematical object named a free monoid. So it is just a different mathematical sense :wink: Also,

Could it? Type level integers form a ring, just like an ordinary integer. I argue that the similarly-looking and similarly-meaning types should have the same set of operators and operations.

Here goes a complication with extending lexical tokens. I think that, as far as I know, introducing a new multi-letter token which doesn't contain any previously invalid letter breaks a backward compatibility with macros by examples (i.e. macro_rules! style):

macro_rules! t {
    (+ $x:tt) => ()
}

// used to compile, but no longer compiles with the addition of ++
t!(++);

Note that we already have similar problems with the treatment of >>, && and ||---they have to be split as the parser requires, and the macros cannot directly request the split. In that regard, a single-letter token is much better candidate than others.

This may help a lot. It seems that there are not much alternatives there (except that ~ is also used by Perl 6).

6 Likes