Lisp HUG Maillist Archive

bug in pprint with circular lists in structures?

Hello all,
I'm wondering if this is a bug. I'm not sure, as I'm having a hard time
tracking down the inter-dependencies between the various
*print-xxx*variables.

In CLISP:


[1]> (setf *print-circle* t)
T
[2]> (print '#1=(1 2 3 . #1#))

#1=(1 2 3 . #1#)
#1=(1 2 3 . #1#)
[3]> (pprint '#1=(1 2 3 . #1#))

#1=(1 2 3 . #1#)

[4]> (defstruct foo l)
FOO
[5]> (print (make-foo :l '#1=(1 2 3 . #1#)))

#S(FOO :L #1=(1 2 3 . #1#))
#S(FOO :L #1=(1 2 3 . #1#))
[6]> (pprint (make-foo :l '#1=(1 2 3 . #1#)))

#S(FOO :L #1=(1 2 3 . #1#))


But in Lispworks: (LWM 4.4.5):

CL-USER 1 > (setf *print-circle* t)
T

CL-USER 2 > (print '#1=(1 2 3 . #1#))

#1=(1 2 3 . #1#)
#1=(1 2 3 . #1#)

CL-USER 3 > (pprint '#1=(1 2 3 . #1#))

#1=(1 2 3 . #1#)

CL-USER 4 > (defstruct foo l)
Foo

CL-USER 5 > (print (make-foo :l '#1=(1 2 3 . #1#)))

#S(Foo :L #1=(1 2 3 . #1#))
#S(Foo :L #1=(1 2 3 . #1#))

CL-USER 6 > (pprint (make-foo :l '#1=(1 2 3 . #1#)))

;; and then it hangs here until I break manually.


I'm having a hard time determining what the behavior
*should* be (if it's even specified), and whether or not
there's a bug here, or if I should be doing something
with set-pprint-dispatch, &c,

Thanks!


-- 
=====================
Joshua Taylor
tayloj@rpi.edu

"A lot of good things went down one time,
     back in the goodle days."
               John Hartford


Re: bug in pprint with circular lists in structures?

Sorry to reply to my own message, but I had posted this on
comp.lang.lisp as well, and only just recently got a response
suggesting that this is a bug, and not implementation specific
behavior.

So, should pprint respect *print-circle* ?

On 2/22/07, Taylor, Joshua <tayloj@rpi.edu> wrote:
> Hello all,
> I'm wondering if this is a bug. I'm not sure, as I'm having a hard time
> tracking down the inter-dependencies between the various
> *print-xxx*variables.
>
> In CLISP:
>
>
> [1]> (setf *print-circle* t)
> T
> [2]> (print '#1=(1 2 3 . #1#))
>
> #1=(1 2 3 . #1#)
> #1=(1 2 3 . #1#)
> [3]> (pprint '#1=(1 2 3 . #1#))
>
> #1=(1 2 3 . #1#)
>
> [4]> (defstruct foo l)
> FOO
> [5]> (print (make-foo :l '#1=(1 2 3 . #1#)))
>
> #S(FOO :L #1=(1 2 3 . #1#))
> #S(FOO :L #1=(1 2 3 . #1#))
> [6]> (pprint (make-foo :l '#1=(1 2 3 . #1#)))
>
> #S(FOO :L #1=(1 2 3 . #1#))
>
>
> But in Lispworks: (LWM 4.4.5):
>
> CL-USER 1 > (setf *print-circle* t)
> T
>
> CL-USER 2 > (print '#1=(1 2 3 . #1#))
>
> #1=(1 2 3 . #1#)
> #1=(1 2 3 . #1#)
>
> CL-USER 3 > (pprint '#1=(1 2 3 . #1#))
>
> #1=(1 2 3 . #1#)
>
> CL-USER 4 > (defstruct foo l)
> Foo
>
> CL-USER 5 > (print (make-foo :l '#1=(1 2 3 . #1#)))
>
> #S(Foo :L #1=(1 2 3 . #1#))
> #S(Foo :L #1=(1 2 3 . #1#))
>
> CL-USER 6 > (pprint (make-foo :l '#1=(1 2 3 . #1#)))
>
> ;; and then it hangs here until I break manually.
>
>
> I'm having a hard time determining what the behavior
> *should* be (if it's even specified), and whether or not
> there's a bug here, or if I should be doing something
> with set-pprint-dispatch, &c,
>
> Thanks!
>
>
> --
> =====================
> Joshua Taylor
> tayloj@rpi.edu
>
> "A lot of good things went down one time,
>      back in the goodle days."
>                John Hartford
>


-- 
=====================
Joshua Taylor
tayloj@rpi.edu

"A lot of good things went down one time,
     back in the goodle days."
               John Hartford


Updated at: 2020-12-10 08:46 UTC