Operators for everything (was Re: Operators for matrix)

Greg Ewing to_get_my_address at see.my.signature
Wed Jul 26 23:37:22 EDT 2000


Cliff Crawford wrote:
> 
> They sorta remind me of Smalltalk's keyword messages:

Hmmm, I must say that

   A mmul: B

looks rather less ugly to me than

   A @mmul B

There are a couple of reasons for this, I think. One is
that I find @ to be an ugly symbol in itself to begin
with. The other is that it comes with a preconceived
pronunciation -- in my mind I hear "A at mmul B" and
think "what the &^%#* does that mean?" Whereas the
colon doesn't normally have a pronunciation, so the
first one sounds better. Also, it harmonises with the
usual way of using a colon in English.

However, I don't think that any of this sort of thing 
is going to satisfy the mathematicians. Infix operators
work not only because they are infix, but because they
are extremely compact, allowing very complicated
formulas to be expressed concisely yet readably.

The requirement for readability is where all of the
proposals for non-alphabetic symbol combinations fall
down as well, to my eyes. Even the claimed-to-be-superior

   (1~+2)~*3 ~- 4 == (10~/2)~^1

doesn't look much better to me than any of the others.
When I look at that, the first thing I see is a whole
bunch of tildes, and I have to look quite hard to pick
out exactly what is after each tilde. It also doesn't
help that

   1~+2

looks rather like

   1 ~ +2

etc.

If I had to decide on some set of multi-character operators,
I think I would have to go for one of the bracketed sets
that have been suggested. And it would probably have to
be {}. Both () and [] clash too much with their other
uses in an expression, and <-> looks too arrowish. It's
unlikely that dictionary construction is going to be used
in a linear algebra expression very often, though.

   A = 3*B{*}C + (D{*}e - F{*}g) {-} H{/}J

Not all that great, but at least it has a chance of
being read.

I think we're just going to have to wait for Unicode
before we can solve this in a really satisfactory way,
folks.

-- 
Greg Ewing, Computer Science Department, 
University of Canterbury, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list