Gmane
From: Norbert Nemec <Norbert.Nemec.list@...>
Subject: Idea: elementwise operators: [+], [*], ...
Newsgroups: gmane.comp.lang.boo.devel
Date: 2005-06-27 15:47:51 GMT (4 years, 1 week, 6 hours and 52 minutes ago)
Hi there,

thinking further about the clash of + as addition and concatenation, I
had an even better idea:

How about generally introducing [+], [*] and so on as elementwise
operations? This avoids the clash with the double meaning of + and *,
adds to the readability, since you see whether an operation handles
objects or collections offers a number of cool possibilities:

    A = [1,2]
    B = [3,4]
=>
    A + B == [1,2,3,4]  # as before
    A [+] B == [4,6]
    A [*] B == [3,8]

If one of the arguments is not a list, it is distributed:

    A [+] 1 == [2,3]

One could handle lists of strings:
    C = ["hi","hello"]
    D = ["there","dude"]
=>
    C [+] " " [+] D [+] "!"== ["hi there!","hello dude!"]

In the language definition, the brackets need not just add a bunch of
new operators, but they could also be defined as a "modifier" for any
existing operator. This would mean that they can even be nested:

    E = [[1,2],[3,4]]
=> E [[*]] 2 == [[2,4],[6,8]] 

Probably, there are even more possibilities...

I'm not sure yet, in which way this should be overloadable. It would
certainly be important to allow user-defined structures to offer this,
but I don't see any obvious way yet how this should work.

Greetings,
Norbert