DWIM reference in Lisp In Small Pieces

11 views
Skip to first unread message

Tim Daly

unread,
Jun 4, 2023, 6:54:36 PM6/4/23
to Larry Masinter, Medley Interlisp Users/Interest, Medley Interlisp core
In Lisp In Small Pieces[0] (a must-read book) on page 40 DWIM is mentioned

The question under discussion is enriching the function environment. To quote:

Finally, we could even allow the function to be in the second position in order to
simulate infix notation. In that case, (1 + 2) should return 3. DWIM (that is, Do
What I Mean) in [Tei74, Tei76] knows how to recover from that kind of situation.

All these innovations are dangerous because they reduce the number of erroneous
forms and thus hide the occurrence of errors that would otherwise be easily
detected. Furthermore, they do not lead to any appreciable savings in code, and
when everything is taken into account, these innovations are actually rarely used.
They also remove that affinity between functions and applicable functional objects,
that is, the objects that could appear in the function position. With these innovations,
a list or a number would be applicable without so much as becoming a function
itself. As a consequence, we could add applicable objects without raising an error:

   (apply (list 2 (list 0 (+ 1 2))) '(foo bar hux wok) ) -> (hux (foo wok))

Tim


Larry Masinter

unread,
Jul 23, 2023, 9:55:24 AM7/23/23
to Tim Daly, Medley Interlisp Users/Interest, Medley Interlisp core
DWIM was the ChatGPT of the day. A lot of the problems with this and other analyses are that
* DWIM isn't a single feature. It's part of a suite of tools that work together.
* DWIM (usually) only gets into the picture if otherwise it would signal an error.
* The infix notation usually only happens once and then THE SOURCE CODE is modified.

Personally I never used infix CLisp for arithmetic. I would use it for record access 
(RECORD RN (F1 F2 F3)) then 
 X:F1 instead of (fetch F1 of X) and 
 X:RN.F1_Y instead of (replace (RN F1) of X with Y)
  -- using a font where _ was a left arrow. This doesn't work so well when : is the package delimiter. I  don't think you'll find any infix in any of the Medley repositories, although the code implementing it is still there.

This is a case where the original not-so-bad-but-not-great idea got buried by other features.
 If we want to allow people to experience Lisp with infix notation in practice, we could make an exec (REPL) with OLD-INTERLISP-T readtable which treats : as an ordinary character and uses control-uparrow as the package delimiter. I think for arithmetic that IPLUS was preferred to PLUS anyway.

image.png
--
Reply all
Reply to author
Forward
0 new messages