Search code examples
debiancommon-lispclisp

*print-escape* not behaving correctly on Debian?


I'm learning clisp at the university and in one of the textbook, when learning about characters, encoding and so on, I am taught that

  • print-escape is set to nil by default in the toplevel
  • when print-escape is null, then characters are printed as such like this ( > being the clisp prompt):
> #\newline
#\nEWLINE
> #\space
#\sPACE
> #\a
#\a
  • when print-escape is assigned whatever other value (eg. using (setq print-escape t) ), then characters are shown the way they "really" are (I don't know how to really explain that but I think you get what I mean):
> (setq *print-escape* t)
t
> #\newline


> #\space

> #\a
a

The problem that I have is that I installed clisp (version 1:2.49-8.1) on Debian Wheezy and I don't get the same results at all but the exact opposite: - print-escape returns t for me by default - the character are printed as characters (ie #\a => #\a) with print-escape being set to t and as they "really" are (ie #\a => a) after I set print-escape to nil.

So sounds like there's a mistake in the course material right? Or are there any other clisp top level variables that could have an influence on this and that might be set differently in Debian so that I get the exact opposite result / behavior?


Solution

  • You can look up the Common Lisp standard (CLisp is an implementation of Common Lisp) at the Common Lisp Hyperspec (search for CLHS *print-escape*, or use the search at http://l1sp.org, or use http://l1sp.org/cl/*print-escape*).

    The standard says that it is bound to t by default and that an implementation attempts to print things in such a way that reading them back in produces a value that is equal to the one printed.

    The CLisp implementation notes (http://www.clisp.org/impnotes.html) make no mention of characters in conjunction with *print-escape*. Since it does make a serious attempt to print readably in many other cases, I think that what you see is the expected and intended behaviour.

    There is much implementation dependency in this however. For example, #\space might be printed as #\ (sharpsign backslash space) by other implementations.