Beyond Typewriter-Styled Code in Swift, Adoption of Symbols

Furthermore, I would argue that using `+` for matrices is more consistent

than the current definition of `+`.

Indeed, the operator `+` is both used for combining numbers and combining

arrays/strings.

The inconsistency comes from the fact that it is expected that `+` is a

commutative operator,

but concatenation is not a commutative operation. Therefore the semantics

of `+` varies

depending on the types that it’s used on. And, in my opinion, this

inconsistency is to be

avoided when dealing with operators. Not to mention that nothing prevent

a library to override

`+` with any nonsensical behaviour.

how would you multiply matrices, or multiply matrix by a number? let's say
you will use * for that. but matrix x matrix multiplication is not
commutative (while matrix x number is). would you propose to use ** instead?

if i have:

func * (m: Matrix, n: Double) -> Matrix

with * somehow marked "commutative", shall i be able using it as n*M
straight away without having explicit:

func * (n: Double, m: Matrix) -> Matrix

while using + for string concatenation is a long standing tradition it
is indeed a bit awkward (as awkward as 1 + 2 = 12 would be)

Mike

···

on Fri, 1 Sep 2017 00:40:25 +0200 André Videla <andre.videla@gmail.com> wrote: