Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#434 pprint-newline does not respect logical-block boundaries

open
Bruno Haible
clisp (525)
9
2008-02-08
2007-12-27
No

1. What is your platform (uname -a on a UNIX system)? Compiler version? GNU libc version (on GNU/Linux)?
Linux hedwig 2.6.22-14-generic #1 SMP Tue Dec 18 08:02:57 UTC 2007 i686 GNU/Linux

2. Where did you get the sources or binaries? When? (Absolute dates - like “2006-01-17” - are preferred over the relative ones - like “2 days ago”).
Today (December 27, 2007, ~2:30p PST)

3. How did you build CLISP? (What command, options &c.)
./configure --build build
(FFI, libsigsegv and readline all present)
4. What is the output of clisp --version?

GNU CLISP 2.43 (2007-11-18) (built 3407780871) (memory 3407781159)
Software: GNU C 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
gcc -g -O2 -Igllib -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -O2 -fexpensive-optimizations -falign-functions=4 -DUNICODE -DDYNAMIC_FFI -I. -x none /usr/local/lib/libreadline.so -Wl,-rpath -Wl,/usr/local/lib -lncurses -ldl /usr/local/lib/libavcall.a /usr/local/lib/libcallback.a -L/usr/local/lib -lsigsegv -lc
SAFETY=0 HEAPCODES LINUX_NOEXEC_HEAPCODES GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.5
libreadline 5.2
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP
LISP=CL INTERPRETER SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI
GETTEXT UNICODE BASE-CHAR=CHARACTER PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /home/aneil/src/clisp/build/
User language: ENGLISH
Machine: I686 (I686) hedwig

5. Please supply the full output (copy and paste) of all the error messages, as well as detailed instructions on how to reproduce them.

I think there is a problem in the pretty printer. I've attached some code which installs a pretty-print function for a structure called pretty-struct.

I create a sequence of nested structures, and allow the pretty printer to print it. The result on SBCL, CMUCL and Lispworks is as expected:
[pretty-struct
[pretty-struct
[pretty-struct
[pretty-struct
[pretty-struct 1]]]]]

However, on CLISP, I get:
[pretty-struct
[pretty-struct
[pretty-struct
[pretty-struct
[pretty-struct
1]]]]]

Here is a transcript of my session:
$ src/clisp/build/clisp
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8

Welcome to GNU CLISP 2.43 (2007-11-18) <http://clisp.cons.org/>

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2007

Type :h and hit Enter for context help.

[1]> (lisp-implementation-version)
"2.43 (2007-11-18) (built 3407780871) (memory 3407781159)"
[2]> (in-package cl-user)
#<PACKAGE COMMON-LISP-USER>
[3]>
(defstruct pretty-struct value)
PRETTY-STRUCT
[4]>
(defun pretty-struct-pprinter (stream sobj)
(pprint-logical-block (stream nil :prefix "[" :suffix "]")
(princ "pretty-struct" stream)
(pprint-newline :linear stream)
(pprint-logical-block (stream nil)
(princ #\space stream)
(prin1 (pretty-struct-value sobj) stream))))
PRETTY-STRUCT-PPRINTER
[5]>
(set-pprint-dispatch 'pretty-struct #'pretty-struct-pprinter 100)
NIL
[6]>
(defun make-recursive-pretty-struct (n)
(if (<= n 1) (make-pretty-struct :value 1)
(make-pretty-struct :value (make-recursive-pretty-struct (1- n)))))
MAKE-RECURSIVE-PRETTY-STRUCT
[7]> (make-recursive-pretty-struct 5)
[pretty-struct
[pretty-struct
[pretty-struct
[pretty-struct
[pretty-struct
1]]]]]

Discussion

  • Logged In: YES
    user_id=870521
    Originator: YES

    1. Forgot to answer question 2 completely - source is a fresh CVS checkout.
    2. The print formatting problem is lost in the comments - please see comments in attached file

     
  • demonstrates pprint-newline problem

     
    Attachments
  • Logged In: YES
    user_id=870521
    Originator: YES

    File Added: clisp-pprint-bug.lisp

     
  • Logged In: YES
    user_id=870521
    Originator: YES

    Hi - Is there any chance that a fix for this can get into the 2.44 release?
    I have a project (http://sourceforge.net/projects/littleb/) that *really*
    depends on this functionality that I'd like to have running on CLISP.

    I need to print complex hierarchical objects. Currently, the print system
    doesn't correctly set the column when pprint-logical-block is used, and this
    results in *tons* of extra whitespace, in my case, which makes the output
    unreadable - e.g., an indented object may appear several lines down in the
    terminal because of extra whitespace printing.

     
    • priority: 5 --> 9
     
  • Sam Steingold
    Sam Steingold
    2008-02-11

    Logged In: YES
    user_id=5735
    Originator: NO

    2.44 is already out, but if this issue is so important to you, you can fix it yourself and submit a patch.
    please note that given our limited resources we cannot always fix bugs as fast as you (and we!) want.

     
  • Logged In: YES
    user_id=870521
    Originator: YES

    > 2.44 is already out, but if this issue is so important to you, you can fix
    it yourself and submit a patch.

    I'd love to. The relevant code seems to be in C. Can you point me at some documentation for how system functions written in C are structured and called? (I searched but couldn't turn up anything.)

    Thanks for the help,

    Aneil

     
  • Sam Steingold
    Sam Steingold
    2008-02-11

    Logged In: YES
    user_id=5735
    Originator: NO

    all code & docs are in src/io.d & src/pprint.lisp.
    you may also found http://clisp.cons.org/impnotes/add-fun.html useful