[pro] Learning Lisp the Bump Free Way
Tord Romstad
tord.romstad at gmail.com
Fri Jan 21 10:20:25 UTC 2011
On Thu, Jan 20, 2011 at 10:22 PM, karol skocik <karol.skocik at gmail.com> wrote:
> Some time ago, I tried to communicate on IRC channel about a very,
> very simple addition:
> string+, which is obviously a nice, small name for (apply
> #'concatenate 'string strings).
Pet peeve: string+ is a *small* name, but it is not a *nice* name for
string concatenation. Additive notation for string concatenation is
extremely ugly and counter-intuitive for anyone who has studied
mathematics. It is extremely annoying that C++, JavaScript and a few
other languages have adopted this convention. Additive notation is
normally used for commutative operations, which string concatenation
is not.
There already is a standard notation for string concatenation, from
long before the days of computers and programming languages.
Mathematically, strings under concatenation is the free monoid
(http://en.wikipedia.org/wiki/Monoid) over the set of all available
characters. The single binary operation in a non-commutative monoid is
nearly always written as multiplication. And even if you don't know
anything about abstract algebra, multiplicative notation makes much
more sense: After all, even in elementary high school algebra, abc*de
equals abcde, but abc+de does not.
Therefore, if you really need a function for string concatenation and
want to share it with the world, please name it string*, not string+
Tord
More information about the pro
mailing list