Differences between Scheme and Common Lisp

Size of the language

Some of these features include: packages, arrays, structures, hash tables, object-oriented programming features, a powerful macro feature for extending the language, generalized assignment, and much more.

Numbers

Common Lisp, by contracts, requires every implementation to support floating point numbers, rational numbers, integers of arbitrary precision, complex floating point number, and complex rational numbers. This fact makes programs that use numbers more portable.

Tail call optimization

No such rule exists in Common Lisp, although many Common Lisp compilers actually do optimize tail calls. It is therefore less frequent in Common Lisp to use tail recursion for (say) traversing lists. Instead, Common Lisp has a rich set of iteration primitives for exactly that purpose.

Program/data equivalence

For instance, in Scheme, there is a difference between:

(define (f x y . (z)) ...)

(define (f x y z) ...)

read

read

Common Lisp, on the other hand, does require two such forms to be equivalent. This feature is the very basis of the Common Lisp macro system, which uses Lisp data to represent and manipulate Lisp code.

Since no such equivalence exists in Scheme, one can argue that it is impossible to ever have a good macro system for Scheme. In practice, of course, nearly all implementations do define the equivalence and do contain macro systems.

Multiple namespaces

The main idea in Common Lisp is that the name fun in an expression such as:

(fun arg)

arg

fun

Perhaps the most obvious difference is that in Common Lisp, it is possible to use the name of a function as an ordinary value without shadowing the function. This is possible in Common Lisp, but not in Scheme:

(let ((list '(1 2 3))) (list list))

(list list)

list

let

On the other hand, this is possible in Scheme but not in Common Lisp:

(let ((fun (compute-a-function))) (fun x y))

fun

funcall

(let ((fun (compute-a-function))) (funcall fun x y))

fun

funcall

funcall

We have seen how Common Lisp through the built-in function funcall is able to call a function that is the value of an ordinary variable. We must also solve the inverse problem, i.e., obtain the function object that is not the value of an ordinary variable, but only the global function value of some name such as car .

This is possible in Scheme:

(map car l)

car

function

#'

map

mapcar

(mapcar #'car l)

Minor variations in syntax

define

(define (f l) (g (reverse l)))

defun

(defun f (l) (g (reverse l)))

set!

setq

map

mapcar