Context Dependent Syntax, Lisp setf, Python a[i]=x

By Xah Lee. Date: .

Common Lisp setf is Worst Computer Language Design

the Common Lisp setf is the most fk'd design in computer languages possible.

languages with a[i]=x, are also fk'd. It's the confounding of meaning. It is exception, irregularity.

here's elisp manual explaining setf. (info "(elisp) Generalized Variables")

Let's talk about a[i] = x, and see what's wrong.

the gist here, is that it uses the same notation to indicate a “place”. For example, a[3] is the 3rd element in array. So,

a[3]=4 means make the 3rd place to have value of 4.

The problem here, is that there's different semantic meaning of a[3] in the 2 cases. Normally, a[3] evaluates to a value. But in a[3]=4, the a[3] does not evaluate. Rather, it's part of the syntax that tells the compiler of a “storage location”.

So, you see, the a[3] in print a[3] and a[3]=4 have diff meaning, and is context dependent.

And of course Forth also explicitly has fetch and store ops so you can say 3 a @ . and x @ 3 a ! for printing and assignment

The Bliss language (DEC Systems lang) had a unary dot operator to return a value so you'd say a[3]=.x and print .a[3]

—from Bahstin Beer Bum @mmaug, 2016-10-05