1 July 2024
Article published by: wxie
Date of publication: 1 July 2024
Recently, I read again the book “Evolution of Lisp” by Gay L. Steele Jr. and Richard P. Gabriel. I am interested in the discussion of NIL in the history of lisp. Here I have made some experiement about them in SBCL (Common Lisp) and Guile (Scheme).
system | input | result | comment |
---|---|---|---|
SBCL | nil | NIL | regardless of capitalization |
SBCL | () | NIL | |
SBCL | ’() | NIL | |
SBCL | t | T | regardless of capitalization |
SBCL | (atom nil) | T | |
SBCL | (listp nil) | T | |
SBCL | (atom ()) | T | |
SBCL | (atom ’()) | T | |
SBCL | (listp ()) | T | |
SBCL | (listp ’()) | T | |
SBCL | (null nil) | T | |
SBCL | (null ()) | T | |
SBCL | (null ’()) | T | |
SBCL | (first nil) | NIL | |
SBCL | (first ()) | NIL | |
SBCL | (rest nil) | NIL | |
SBCL | (rest ()) | NIL | |
SBCL | (atom t) | T | |
SBCL | (listp t) | NIL | |
SBCL | (null t) | NIL | |
Guile | nil | unbound | |
Guile | t | unbound | |
Guile | () | syntax error | |
Guile | ’() | () | |
Guile | (list? ’()) | #t | |
Guile | (pair? ’()) | #f | |
Guile | (car ’()) | wrong type | expecting pair |
Guile | (cdr ’()) | wrong type | expecting pair |
Guile | #f | #f | false |
Guile | #t | #t | true |
Guile | #false | #f | false |
Guile | #true | #t | true |
So it’s clear that NIL is a complex thing in Common Lisp, while Scheme avoids this.
Markdown file for this page: https://wxie.codeberg.page/blog/nil-t-in-lisp.md
Subscribe to RSS for this site
This HTML page was generated by the Untitled Static Site Generator.