I am trying to better understand how S-expressions are evaluated in different foxes, and would like them to handle interesting poorly formed expressions. I understand that Common Lisp and Scheme are completely different languages, but is there any difference in their semantics that explains the difference in behavior. For example, Lisp -1s and Lisp -2s have observed differences in their behavior, as well as hygienic and unhygienic macro systems.
I have a program that contains an unreachable poorly formed if statement in Scheme and Common Lisp.
;; foo.scm
(if #t 1 (if))
(display "12")
And the general version of Lisp
;; foo.lisp
(if t 1 (if))
(display "12")
chickenand guilegenerate a syntax error.
Chick:
% chicken foo.scm
Syntax error: (foo.scm:1) in `if' - pair expected
(if)
Expansion history:
<syntax> (##core#begin (if #t 1 (if)))
<syntax> (if #t 1 (if))
<syntax> (##core#if #t 1 (if))
<syntax> (if) <--
Insidiousness:
% guile foo.scm
...
.../foo.scm:1:9: source expression failed to match any pattern in form (if)
sbcland clispboth type 12 and give no warning.
SBCL:
% sbcl --load foo.lisp
This is SBCL 1.3.11, an implementation of ANSI Common Lisp.
...
12
0]^D
CLISP
% clisp foo.lisp
"12"