Content-Type: text/shitpost


Subject: Abutment for multiplication and other things
Path: you​!your-host​!warthog​!goatrectum​!plovergw​!plovervax​!shitpost​!mjd
Date: 2017-11-28T15:03:39
Newsgroup: talk.mjd.multiplication-stars
Message-ID: <a890a75dd710c531@shitpost.plover.com>
Content-Type: text/shitpost

A few days ago I mused:

Perhaps someone once invented a programming language that used simple abutment for multiplication, the way mathematics does? But while I know a couple of languages that use abutment to mean string concatenation, I have never seen it used for multiplication.

Gentle Readers wrote in with examples.

  • Roman Cheplyaka pointed out that the Wolfram language, used by Mathematica, has an invisible multiplication operator.

  • Russell Borogove referred me to this 1998 proposal, by Bjarne Stroustrup, to allow overloading of whitepsace in C++.

    I only skimmed this, but I'm not sure I want to read the whole thing. The impression that I have now is that I'd shrug and say something like “of course it's a tragedy, but what did you expect would happen if you let this guy back on the streets?”

    (By the way, M. Borogove, and everyone else: I now read Twitter only very irregularly and infrequently, so it is not a good way to get in touch with me. Email will work better.)

  • Simon Tatham referred me to his useful-seeming Spigot utility that has an expression parser that interprets abutment as multiplication.

E.W. Dijkstra's magnificent body of unpublished napkin notes (pardon me, ‘manuscripts’) contains a discussion of “invisible operators”. Complaining about the invisible multiplication sign, he says:

One price is confusion: look at the different semantics of $$ 3½\qquad 3y\qquad 32$$

Languages that use abutment for string concatenation include SNOBOL, REXX, and awk. Also the C preprocessor from C90 forward. I was going to say I thought this was the only choice of concatenation operator that was worse than overloading +, a perennial choice that has had me shaking my head sadly for decades. But in the context of the C preprocessor, abutment makes sense, and in SNOBOL it works better than you'd expect.

“It’s weird, but it works better than you'd expect” might be SNOBOL's official motto. I would like to visit the alternate universe in which SNOBOL was as influential as ALGOL 60. It might not work as well, but it would be charming. People would wear hats with antennas sticking up, and everything would be decorated with rocket fins.

SNOBOL also uses abutment to indicate concatenation of patterns, which, because of the semantics of pattern execution, is rather like using it for execution sequencing. That is, if FOO and BAR are patterns, then FOO BAR is a pattern that tries to match FOO and then tries to match BAR. Regular expression syntaxes down to the present behave similarly: the concatenation operator is invisible.

Many languages, such as Haskell, use abutment as functional application: f x y means to apply function f to argument x, then apply the result to argument y.

I think Larry Wall once said that you can tell what a language thinks is important by looking at what it uses the $1 notations to mean. The shell is all about running commands, so the shell uses $1 to access the command arguments. Perl is about pattern matching, so it uses $1 to access the results of a pattern match. Maybe the theory is more plausible if you formulate it about invisible operators instead.