<< Back to previous view

[CLJ-695] pprint does not respect *print-length* Created: 18/Dec/10  Updated: 01/Mar/13  Resolved: 31/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.3

Type: Defect Priority: Major
Reporter: Stuart Halloway Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0695-partial-fix.patch     File pprint-print-length-fix.diff    
Patch: Code and Test
Approval: Ok


pprint does not respect print-length – instead it prints ellipses for every element one length is passed (and prints forever on infinite collections).

Comment by Stuart Halloway [ 18/Dec/10 3:14 PM ]

The attached patch is part of a possible fix. Issues to run down:

  • where and how is the return value of write-out used. (The changes I make eliminate this dependency in favor of a direct check of the dynamic variables.
  • how to make sets work? they are in a different code path than the others
Comment by Tom Faulhaber [ 21/Dec/10 2:36 AM ]

Hmm, looks like I broke some logic when I hand unrolled the original cl-format based dispatch to get better performance for lists, vectors, and maps. (Really I shouldn't have to do this, but I need to make cl-format itself generate code rather than threaded functions which are slow and tend to blow your stack. Haven't gotten around to that yet, though so the hand-coded versions are stop-gaps.)

I'm not digging the patch too much, though, for 3 reasons:

1) It breaks sets and arrays, which work in master.
2) It pushes the logic for print-length printing into the dispatch functions (redundantly since there's still logic in write-out). Since these are customizable, it places that load on whoever customizes it.
3) It adds redundant logic in write-out which is the called for every object that the pretty printer deals with.

I'll try to take a stab at a patch that fits a little better with what I'm trying to do in the next couple of days.

Comment by Tom Faulhaber [ 22/Dec/10 3:13 AM ]

This fixes the the issue with hand-rolled dispatch functions and provides a macro to help other users do it correctly as well.

Comment by Stuart Halloway [ 22/Dec/10 9:03 PM ]

Second patch is good. This is more important because apparently the IDE REPLs use pprint by default.

Generated at Sun Oct 22 14:22:30 CDT 2017 using JIRA 4.4#649-r158309.