4 ms·
> Such a strange statement! Code IS data in Lisp. Code is represented as data. But that does not mean any data is code. For example (defun foo (a) (let (
by lispm 13y ago
> Such a strange statement! Code IS data in Lisp.
Code is represented as data. But that does not mean any data is code.
For example
(defun foo (a) (let ((b 10)) (+ a b)))
is valid data and valid code.
(defun (foo a) (let b 10 then (+ a b)))
Above is valid data, but not valid code.
CL-USER 27 > (defun (foo a) (let b 10 then (+ a b)))
Error: (FOO A) is neither of type SYMBOL nor a list of the form (SETF SYMBOL).
The syntax for DEFUN is:
defun function-name lambda-list [[declaration* | documentation]] form*
The syntax for LET is:
let ({var | (var [init-form])}*) declaration* form*
Both syntax definitions are violated.
Obviously, the syntax of s-expressions is not enough to describe the syntax of Lisp. Far from it. S-Expressions just describe a textual syntax for data: symbols, numbers, strings, lists, cons cells, ... But it does not describe the syntax for defining functions, defining variables, exception handlers, function calls, etc.
> They just choose not to because s-expressions are a pain in the ass to read.
They aren't.
> Isn't the whole point to get away from imperative style?
Lisp makes no commitment to a particular style. 'imperative' is just fine. As is functional, object-oriented, rule-based, ...