On Thu, Jul 3, 2014 at 9:45 AM, Stefan Karpinski <ste...@karpinski.org>
wrote:

> On Thu, Jul 3, 2014 at 9:42 AM, Ivar Nesje <iva...@gmail.com> wrote:
>
>> We should really create a simple system where you can get those hints
>> printed in the REPL, without defining more methods.
>
>
> Yes, I think we should really pursue this avenue.
>
> For what it's worth – and perhaps something since I'm the original
> perpetrator of the str*str concatenation syntax – I've come to regret this
> operator choice. My reasoning at this point is that we want our operators
> to have fairly "pure" meanings. I chose str*str because concatenation can
> be viewed as a kind of multiplication in the ring of string patterns
> (alternation in the regex sense is the addition operation, the empty string
> is the unit and the non-matching pattern is the zero). However, many
> operations can be viewed as a form of multiplication. In the max-plus
> algebra <http://en.wikipedia.org/wiki/Max-plus_algebra>, for example,
> addition is the multiplication operator. So, at this point I think we
> should stick to very pure classical meanings for operators in Base – the
> Base.* function should be just addition of numbers in the classical sense,
> not the broader sense of addition in any conceivable ring.
>

Hi!

I would add "minimal" and "intuitive".  I agree '*' is an unfortunate
choice for a string concat op, but I don't see a problem with '+' -
mathematics routinely overloads symbols, and I don't see any strictly
mathematical reason to privilege commutativity as an essential component of
the meaning of '+'.  Commutativity is an add-on that comes after the more
primitive sense of accumulation, which is what concatenation is.  You can't
build a brick wall from the top down.  I think its a pretty safe bet that
nobody would ever be tempted to think "ab" + "cd" = "cd" + "ab", ditto for
"++".  On the other hand, if you want to minimize overloading, an
alternative notation (my fav), used by Z and ML, among other languages, is
'^'; since that's already taken, maybe '^^'.

In any case, str * str isn't all that tragic; think of it as a beauty mark,
a flaw that makes the whole face more beautify. ;)

-Gregg Reynolds

Reply via email to