3
votes

I am used to Racket and I am trying to learn Common Lisp. In Racket, symbols evaluate to itself as showns by Dr Racket's REPL:

> 'racket
'racket

In Common Lisp, according to the literature, symbols also evaluate to itself.

Actually, the Evaluation Rule for Quoted Objects is:

A quoted object evaluates to the object itself, without the quote.

While using the REPL (Common Lisp, SBCL and Slime), I get:

> 'common-lisp
common-lisp

I feel I need to be educated on the contrast between the design of the two languages.

Why does that happend? What is the point of doing it that way considering CL's design as a language?

Am I missing something profound around CLOS?

I am still building the foundations to understand better CLOS in the near future.

Thanks

2

2 Answers

10
votes

TL;DR: This has nothing to do with Common Lisp. It is just how DrRacket REPL works. You cannot use Racket to learn CL

The Dr. Racket REPL with #lang racket as language and unaltered options does not give you the results in the interactive window. What it does is to print an equal expression that also evaluate to the same value. The team that designs Racket thought this was easier in a learning process, but I tend to disagree because of these kinds of questions.

Standard Racket evaluates 'common-lisp to common-lisp so a way to get an expression to evaluate the same is to quote it so it shows ' common-lisp in the REPL.

It is pretty much the same as one implementation showing numbers in base 16 and the other base 10. The results B and 11 are the same, just visualized differently.

You can change the output format in language options in Dr Racket to get actual values. Some languages, like the standard scheme report schemes already has this.

6
votes

In Common Lisp, according to the literature, symbols also evaluate to itself

No. Only symbols which have themselves as their value will evaluate to themselves.

CL-USER 17 > foo

Error: The variable FOO is unbound.

Generally we need to quote a symbol. A quoted symbol evaluates to the symbol.

CL-USER 19 > 'foo     ; same as (quote foo)
FOO

One can set the symbol value of FOO to FOO itself:

CL-USER 20 > (set foo 'foo)
FOO

CL-USER 21 > foo
FOO