On Monday, April 27, 2015 at 10:09:23 AM UTC-4, François Fayard wrote:
>
> That's a point. One should see * as a monoid operator rather than
> multiplication in the number meaning. I get it.
>
> But I still believe that we are going way too far. I thought that all
> those algebra stuff "for everyone" was just a bad habit in the french
> education system for mathematics in the 70s (a total disaster if you want
> my point of view as a former math teacher). If you go this far, let me
> state :
> 1) + should not be used for floating point numbers as it is not
> associative (a + b) + c != a + (b + c)
> 2) * should not be used for floating point numbers as it is not
> associative (a * b) * c != a * (b * c)
> If we go this far, we'll be in real trouble.
>
> Yes, + for strings is not commutative. So what? It does not lead to some
> substantial problems.
>
The problem is not there, the problem is elsewhere, when you need to work
with mutable strings, i.e. as Vector{UInt8} or Vector{UInt32}.
+ means something totally different then.
*Any* overloading of numeric / boolean operators that can operator on
Vectors or Arrays causes problems (and is simply confusable).
Using something like [] takes just a minute to figure out, just like
learning that .. in Lua is string concatenation... no confusion.
Using + or * means you are always wondering just what the code is doing.
>
> Anyone coming from another langage will think "abcd" * s as
> "abcd...abcd", not a concatenation of 2 strings. It is especially dangerous
> in a langage where types are not always explicit. I've seen a talk
> yesterday on cppcon 2014 where they enforce C++ guys to code in a way that
> a Python developer should understand unless there is a very good reason not
> to do so.
>
Yes... I also always coded this way, since I was programming in C,C++,
Java, and a language that had strict left-to-right evaluation of
expressions where there was no precedence...
i.e. A + B / C meant (A + B) / C, not A + (B/C), so in my ObjectScript
code, I always wrote (A + B)/C, and in my C/C++/Java code, if I meant A +
(B/C), I wrote it with the parenthesis also, even though they weren't
strictly necessary.
Scott