2 ms·
On the other hand, Lisp gives you variadic functions like (list) (list 1) (list 1 2 3 4). Lisp catches it in a straightforward way when you pass too many param
by kazinator 7y ago
On the other hand, Lisp gives you variadic functions like (list) (list 1) (list 1 2 3 4). Lisp catches it in a straightforward way when you pass too many parameters to a non-variadic function, or fewer than the required number of parameters to any function. (cons 1) is a plain and simple error rather than a correct expression that evaluates to an unintended (lambda (x) (cons 1 x)) term. Macros can provide a clear explicit syntax for partial evaluation in which everything is visibly delimited, like (op cons 1).
- dreamcompiler 7y agoI think you're highlighting the downside of ubiquitous laziness. In a lazy world there's nothing wrong with (lambda (x) (cons 1 x)). But if you want to call this an error earlier, I agree that Lisp defaults in that direction.