first gives errors on empty lists
Posted: Wed May 20, 2009 7:20 pm
Calling (first) on an empty list gives an error instead of returning the empty list. This is inconsistent with the documentation, which claims that first behaves the same as car in other Lisp implementations.
On the contrary,
CL (and Scheme as well, I believe) return empty lists when car or cdr (which are first and rest in NL) are called on empty lists.
This behavior of the function gives a lot of errors in instances where lists are being checked using functions such as filter, which may return empty lists. I doubt that modifying this behavior would cause existing programs to break.
On the contrary,
Code: Select all
; sbcl
This is SBCL 1.0.18.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http>.
* (car nil)
NIL
* (car ())
NIL
This behavior of the function gives a lot of errors in instances where lists are being checked using functions such as filter, which may return empty lists. I doubt that modifying this behavior would cause existing programs to break.