#337 print-object built-in object: no-applicable-method

clisp (525)

CLHS says about PRINT-OBJECT: "Each implementation is
required to provide a method on the class standard-
object and on the class
structure-object. In addition, each implementation
must provide methods on enough other classes so as to
ensure that there is always an applicable method."

Contrary to this, print-object signals a NO-APPLICABLE-
(print-object 2 *standard-output*)
*** - NO-APPLICABLE-METHOD: When calling
with arguments (2 #<IO SYNONYM-STREAM *TERMINAL-
IO*>), no method is

I came across this trying out the CLHS example about
pprint dispatch tables:
(set-pprint-dispatch '(cons (member my-let))
(pprint-dispatch '(let) nil))
With NO-APPLICABLE-METHOD, the following identity
mentioned abour PPRINT-DISPATCH does not hold:
(let ((*print-pretty* t))
(write object :stream s))
== (funcall (pprint-dispatch object) s object)
because pprint-dispatch defers to PRINT-OBJECT which
errors out.

Jörg Höhle


  • Sam Steingold

    Sam Steingold - 2006-07-27

    Logged In: YES

    instead of tediously writing a defmethod for each and every
    built-in class, I would rather have something like

    (defconstant print-object-methods-<instance-of-built-in-class>
    (list (defmethod print-object (obj (out stream)) (write
    obj :stream out))))
    (remove-method #'print-object
    (defmethod compute-applicable-methods-using-classes
    ((gf (eql #'print-object)) args)
    (multiple-value-bind (l p) (call-next-method)
    (if (and (null l)
    (eq (class-of (first args)) <built-in-class>)
    (eq (second args) <stream>))
    print-object-methods-<instance-of-built-in-class> t)
    (values l p))))

    alas, this causes a stack overflow in bootstrap
    and has no effect when type at the prompt.

  • Sam Steingold

    Sam Steingold - 2006-07-27
    • assigned_to: haible --> sds
    • status: open --> closed-fixed
  • Sam Steingold

    Sam Steingold - 2006-07-27

    Logged In: YES

    thank you for your bug report.
    the bug has been fixed in the CVS tree.
    you can either wait for the next release (recommended)
    or check out the current CVS tree (see http://clisp.cons.org\)
    and build CLISP from the sources (be advised that between
    releases the CVS tree is very unstable and may not even build
    on your platform).


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks