Under any Scheme standard, is (let (x y z) x) valid code?

101 Views Asked by At

In both Emacs Lisp and Common Lisp, the following returns nil

(let (x y z)
  x)

yet in every Scheme that I've tried, it throws an error.

Has the above been acceptable under any Scheme standard?

2

There are 2 best solutions below

3
ad absurdum On BEST ANSWER

No, the posted code was never legal in standard Scheme. For all Scheme standards since R1RS (1978) let has had the syntax: (let ((var1 form1) ...) expr1 expr2 ...). The original Scheme paper by Sussman and Steele (1975) did not even use let.

Note that, e.g., (let () 42) is legal in both Scheme and in Common Lisp, i.e., it is legal to have a let form with no bindings.

0
amalloy On

"Any version of Scheme ever" is a very broad brush, and it could take some research to rule out all of history. But in the modern Schemes I know, it is not allowed, and the R5RS standard clearly does not allow it, by specifying that the bindings for a let must come in name/value pairs, and not specifying what a name without a value would mean.