by kazinator · 9y ago · 0 comments
What are M-expressions? Basically this:
(a b c) (quote (a b c))
car[x] (car x)
car[append[(a b c); (d e f)]] (car (append (quote (a b c)) (quote (d e f))))
Parentheses implicitly quote. Square brackets are non-quoting, but the first element goes outside. Inside square brackets, pointlessly superfluous semicolons appear.S-expressions developed the ' notation for quoting, almost eliminating the slight advantage of M-expressions there:
(a b c) '(a b c)
car[x] (car x)
car[append[(a b c); (d e f)]] (car (append '(a b c) '(d e f))))
The apostrophe notation is smarter; I don't see a way in M-exps to quote an individual atom. Though M-exps give us this: (x) (quote (x))
if we want (quote x) it looks as if we have to write: quote[x] 'x
whose lameness is self-evident.I think MacCarthy was exploiting M-expressions for the way that most trivial instances of them look different from S-expressions, which was a useful distinction to have in the papers about Lisp. With an M-exp you could whack the reader over the head and say "hey reader, this is character syntax: what you enter into the machine" and then with S-exps you say "this is a textual picture of internal structure".
There are other ways for that though, like different fonts, or upper/lower case and whatnot, or some REPL convention where we show the prompt in front of what is typed in, plus the "result arrow" and such.
> if we want (quote x) it looks as if we have to write: ... quote[x]
I think that you could just write X in that case. Uppercase text was for symbolic atoms.
Also, you didn't mention conditionals:
M-expressions:
ff[x] = [atom[x] → x; T → ff[car[x]]]
S-expressions: (defun ff (x) (cond ((atom x) x) (T (ff (car x)))))
The semicolon and the infix arrow have the benefit of reducing the need for parentheses in that case. And you can avoid writing "defun" and "cond".