#614 22.1.3.5 conformance

open
Bruno Haible
clisp (525)
5
2011-10-02
2011-10-02
No

As per 22.1.3.5,

(write (quote (john (quote s) weight)) :pretty nil :readably nil)

should print

(JOHN (QUOTE S) WEIGHT)

but instead it prints:

(JOHN 'S WEIGHT)

[and similarly for :readtably t, it prints:

(|COMMON-LISP-USER|::|JOHN| '|COMMON-LISP-USER|::|S| |COMMON-LISP-USER|::|WEIGHT|)
instead of:

(|COMMON-LISP-USER|::|JOHN| (|CL|:|QUOTE| |COMMON-LISP-USER|::|S|) |COMMON-LISP-USER|::|WEIGHT|)
]

========================================================================
Implementation: CLISP 2.49 (2010-07-07) (built 3499302370) (memory 3499302538) on X86_64

Reading of: "(write (quote (john (quote s) weight)) :pretty nil :readably nil)"
signaled no error

Evaluation of: (WRITE '(JOHN 'S WEIGHT) :PRETTY NIL :READABLY NIL)
signaled no error
wrote nothing on *ERROR-OUTPUT*
wrote the following *STANDARD-OUTPUT* (lines excluded):
------------------------------------------------------------------------
(JOHN 'S WEIGHT)
------------------------------------------------------------------------
returned the following value:
--> (JOHN 'S WEIGHT)

========================================================================

Discussion

  • Bruno Haible
    Bruno Haible
    2011-10-03

    Your interpretation of CLHS 22.1.3.5 is debatable.
    CLHS never explicitly says under which conditions it is OK to print (QUOTE FOO) as 'FOO. Likewise for backquote, for which clisp
    has an elaborate algorithm.
    Therefore IMO it's an omission.

    CLHS 22.1.3.5 says "list notation is preferred over dot notation". It does not say "list notation is preferred over quote and backquote notation".

    The description of *print-readably* says that the "standard readtable" can be assumed when reading objects. Therefore you can
    assume that the read-macro for #\' is in place, as much as you can assume that the read-macros for #\( and #\) are in place.

    The rationale for clisp's behaviour is that the symbol QUOTE, when it occurs in lists, most often occurs when printing a piece of a
    program. In this case, printing 'FOO instead of (QUOTE FOO) is always a win in legibility. Changing clisp to print (QUOTE FOO)
    when *print-pretty* is false -- like SBCL does -- would be a regression, IMO.