Clozure / ccl

Clozure Common Lisp
http://ccl.clozure.com
Apache License 2.0
855 stars 103 forks source link

PPRINT-DISPATCH violates clhs. #314

Closed hyotang666 closed 4 years ago

hyotang666 commented 4 years ago

? (lisp-implementation-version) "Version 1.12 (v1.12) LinuxX8664" ? (pprint-dispatch t nil)

Error: The value NIL is not of the expected type STRUCTURE. While executing: CCL::GET-PRINTER, in process listener(1). Type :POP to abort, :R for a list of available restarts. Type :? for other options. 1 > :q

CLHS says

table---a pprint dispatch table, or nil.

kpoeck commented 4 years ago

Seems to be fixed with:

(defun pprint-dispatch (object &optional (table *print-pprint-dispatch*))
  (flet ((non-pretty-print (s object)
           (write-not-pretty s object
                             (if (get-*print-frob* '*print-level*)
                               (- *print-level* *current-level*))
                             nil nil)))
    (let ((fn (get-printer object (or table *standard-pprint-dispatch-table*))))
      (values (or fn #'non-pretty-print) (not (null fn))))))

If nobody objects, will make a pr

hyotang666 commented 4 years ago

CLHS says

If table is nil, retrieval is done in the initial pprint dispatch table.

and

initial pprint dispatch table n. the value of print-pprint-dispatch at the time the Lisp image is started.

so (copy-pprint-dispatch nil) will be used rather than *print-pprint-dispatch* to bind &optional table.

kpoeck commented 4 years ago

If you are trying to say (copy-pprint-dispatch nil)should be used instead of *standard-pprint-dispatch-table*, you are wrong, since *standard-pprint-dispatch-table*is the value of print-pprint-dispatch when the image was started.

If you have another fix in mind, please state it clearly

hyotang666 commented 4 years ago

Oh, I'm sorry, I was wrong. I confused *standard-pprint-dispatch-table* and *print-pprint-dispatch*.

kpoeck commented 4 years ago

ok, than I create the fix