Patch for print-method

4 views
Skip to first unread message

Konrad Hinsen

unread,
Feb 27, 2009, 2:50:43 AM2/27/09
to Clojure
The attached patch to clojure.core fixes the printing problem for
types that have no implementation of print-method. When such objects
are printed or converted to strings, an infinite loop leads to a
stack overflow. The reason is that the :default implementation for
print-method calls str on the object, which in turn calls print-
method again.

The path makes two changes:

1) The current :default implementation becomes the implementation for
Object, thus remaining the default for everything that does not have
a type field in the metadata.

2) A new :default implementation calls print-method recursively after
having removed the :type field from the object's metadata.

Konrad.

print-method.patch

Rich Hickey

unread,
Feb 27, 2009, 7:59:28 AM2/27/09
to Clojure
Patch applied - svn 1311 - thanks!

Rich
Reply all
Reply to author
Forward
0 new messages