3 ms·
Lisp has built-in syntax for example in the form of special operators. LET is an example. LET provides bindings for variables: LET a list of
by lispm 9y ago
Lisp has built-in syntax for example in the form of special operators.
LET is an example. LET provides bindings for variables:
LET
a list of bindings
a sequence of declarations
a sequence of expressions
(LET ((a 1)
(b 2)
c)
(declare (integer a))
(declare (type (integer 0 100) b)
(setq c (+ a b))
(expt c 2))
The EBNF syntax for LET is:
let ({var | (var [init-form])}*)
declaration*
form*
DECLARATION and FORM have more syntax.
If Lisp sees a LET form which does not use above syntax, then it is a syntax error. A compiler or interpreter will tell you that. The compiler will detect that at compile time.
The following forms are all errors:
(let a 10 (+ a 10))
(let (a 10) (+ a 10)) ; 10 is not an identifier
(LET (((A) 10)) (+ a 10)) ; (a) is not an identifier
(let ((a 10)) (+ a 10) (declare (integer a))) ; declaration at wrong place
(let ((a = 10)) (a + 10)) ; Lisp has no infix operators...