Clojure

pprint does not respect *print-length*

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.3
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

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

Activity

Hide
Stuart Halloway added a comment -

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
Show
Stuart Halloway added a comment - 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
Stuart Halloway made changes -
Field Original Value New Value
Attachment 0695-partial-fix.patch [ 10059 ]
Hide
Tom Faulhaber added a comment -

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.

Show
Tom Faulhaber added a comment - 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.
Hide
Tom Faulhaber added a comment -

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

Show
Tom Faulhaber added a comment - This fixes the the issue with hand-rolled dispatch functions and provides a macro to help other users do it correctly as well.
Tom Faulhaber made changes -
Attachment pprint-print-length-fix.diff [ 10061 ]
Tom Faulhaber made changes -
Waiting On tomfaulhaber
Patch Code and Test
Hide
Stuart Halloway added a comment -

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

Show
Stuart Halloway added a comment - Second patch is good. This is more important because apparently the IDE REPLs use pprint by default.
Stuart Halloway made changes -
Approval Vetted Screened
Rich Hickey made changes -
Approval Screened Ok
Stuart Halloway made changes -
Status Open [ 1 ] Resolved [ 5 ]
Resolution Completed [ 1 ]
Stuart Halloway made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: