[comp.lang.misc] String Concatenation

db@lfcs.ed.ac.uk (Dave Berry) (09/13/88)

In article <381@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes:
>ML is not mathematics.

ML is not mathematics, but the Definition of Standard ML is.  It's the formal
specification of the language.

In any case, programming languages aren't used exclusively for maths.
So if there are non-commutative uses of "+", mathematical or otherwise,
it weakens the argument that "+" shouldn't be used for string concatenation.
The amount that the argument is weakened depends on how widespread the
non-commutative uses are.  I won't claim that the single case of the definition
of ML is sufficient!

>It would be *so* sensible to use a "product"
>symbol "x" or even "*" for string concatenation, because it is
>associative with an identity, and exponentiation is exactly the
>right operation for iterated concatenation ("ab"**3 = "ababab").

That makes sense to me, but I wonder how intuitive it would be to novices with
no mathematical background.  "+" is fairly intuitive (to non-mathematical
folks), because it "adds" the second string to the first.

"*" might also get confusing (though probably not ambiguous) in the
presence of regular expressions or if it's also used as a wild card.
 Dave Berry.		 db@lfcs.ed.ac.uk