This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Format's W directive not handling shared structures correctly.


On 11/23/2011 06:47 AM, Charles Turner wrote:
~W wasn't being treated as special case in the ObjectFormat class,
I've changed it to communicate with the pretty printer.

Thanks! Some comments below.


(define a (cons 'a 'z)
(set-cdr! a a)
(format "~W" a)
... OutOfMemory ...

with the patch

(format "~W" a)
#1=(a . #1#) ; as described in
http://www.lispworks.com/documentation/HyperSpec/Body/22_cdc.htm

Actually, my reading the Common Lisp Hyperspec is that ~W does *not* automatically set *print-circle* - it needs to be set explicitly.

However, more to the point is SRFI 48: Intermediate Format Strings
(http://srfi.schemers.org/srfi-48/srfi-48.html).  This *does*
specify that ~W is "WriteCircular", which seems to match your patch.

I fixed your patch to update TracedProcedure.java.  Don't know you
you missed that.

One obviously unpleasing part of this patch is that I'm doing the same
setup/finalisation in ObjectFormat#print as I did in
write-with-shared-structure in ports.scm.

I factored out the common code in my modification.


This patch comes with a change log and a couple of tests.

I added a couple of tests - and I uncovered a bug. This fails:


(define circ2 (cons 'a 'z))
(define circ23 (list circ2 circ2 circ2))
(format "~W" circ23)

The result is "#1=((a . z) #1# #1#)" but IMO it should be
"(#1=(a . z) #1# #1#)".  Could you look into it?

I noticed that the javadoc linked from the Kawa homepage hasn't been
updated for some time (well, my documentation changes aren't in it).
Is that just a no time thing, or am I the only one who's noticed?

It hasn't been a priority - but it would be reasonable to update. -- --Per Bothner per@bothner.com http://per.bothner.com/

Attachment: formatW2.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]