Re: Problem with SBCL pprint
Robert Goldman <[email protected]> Sun, 29 Mar 2026 13:34:24 -0500
| Newsgroups | gmane.lisp.steel-bank.general |
|---|---|
| Message-ID | <[email protected]> |
--===============0136770530029308883==
Content-Type: multipart/alternative;
boundary="=_MailMate_2E8B42F3-79C1-4FE0-91F3-EB2E23497DD3_="
--=_MailMate_2E8B42F3-79C1-4FE0-91F3-EB2E23497DD3_=
Content-Type: text/plain; format=flowed
Content-Transfer-Encoding: quoted-printable
So what is the proper way to control printing of something like integers =
and floats?
Should one do something like this:
(set-pprint-dispatch 'integer
(lambda (stream obj)
(let ((*print-pretty* nil))
(format stream "[~d]" obj)))
0 *ppd*)
Or does one need to handle everything at a much lower level of =
abstraction (i.e., directly wrangling characters)?
I'm not finding examples of managing the printing of numerals that =
clarifies this. So I appreciate being told what's wrong with that code, =
but would also welcome any information about what would be the correct =
approach.
Thanks!
On 27 Mar 2026, at 19:18, Douglas Katzman wrote:
> You realize your printer definitions rely on the Lisp *not* respecting =
> the
> text of CLHS
> <https://www.lispworks.com/documentation/HyperSpec/Issues/iss169_w.htm>=
=
> which
> says that format directives respect *print-pretty* ?
> So it's just a bit funny to imply that there is some SBC-specific fix =
> (for
> what one would infer is a defect) at play.
>
> In file "trythis.lisp":
>
> (defvar *ppd* (copy-pprint-dispatch))
>
> (set-pprint-dispatch 'integer (lambda (stream obj) (format stream =
> "[~d]"
> obj)) 0 *ppd*)
>
> (write 92 :pretty t :pprint-dispatch *ppd*)
>
>
> Armed Bear Common Lisp 1.7.1
>
> Java 25.0.1 Google Inc.
>
> OpenJDK 64-Bit Server VM
>
> Low-level initialization completed in 0.114 seconds.
>
> Startup completed in 0.547 seconds.
>
> Type ":help" for a list of available commands.
>
> CL-USER(1): *(load "trythis.lisp")*
>
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[\
>
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[\
>
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[\
>
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
>
> #<THREAD "interpreter" {5E367A3D}>: Debugger invoked on condition of =
> type
> STORAGE-CONDITION
>
> Stack overflow.
>
>
> ECL (Embeddable Common-Lisp) 24.5.10 (git:294da20f)
>
> Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
>
> Copyright (C) 1993 Giuseppe Attardi
>
> Copyright (C) 2013 Juan J. Garcia-Ripoll
>
> Copyright (C) 2018 Daniel Kochmanski
>
> Copyright (C) 2024 Daniel Kochmanski and Marius Gerbershagen
>
> ECL is free software, and you are welcome to redistribute it
>
> under certain conditions; see file 'Copyright' for details.
>
> Type :h for Help.
>
> Top level in: #<process TOP-LEVEL 0x7fbea6eddf00>.
>
>> *(load "trythis.lisp")*
>
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[\
>
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
>
>
> Condition of type: STACK-OVERFLOW
>
> BINDING-STACK overflow at size 10240. Stack can probably be resized.
>
> Proceed with caution.
--=_MailMate_2E8B42F3-79C1-4FE0-91F3-EB2E23497DD3_=
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/xhtml; charset=3Dutf-8"=
>
</head>
<body><div style=3D"font-family: sans-serif;"><div class=3D"markdown" sty=
le=3D"white-space: normal;">
<p dir=3D"auto">So what is the proper way to control printing of somethin=
g like integers and floats?</p>
<p dir=3D"auto">Should one do something like this:</p>
<pre style=3D"margin-left: 15px; margin-right: 15px; padding: 5px; backgr=
ound-color: #F7F7F7; border-radius: 5px 5px 5px 5px; overflow-x: auto; ma=
x-width: 90vw;"><code style=3D"margin: 0 0; border-radius: 3px; backgroun=
d-color: #F7F7F7; padding: 0px;">(set-pprint-dispatch 'integer
(lambda (stream obj)
(let ((*print-pretty* nil))
(format stream "[~d]" obj)))
0 *ppd*)
</code></pre>
<p dir=3D"auto">Or does one need to handle everything at a much lower lev=
el of abstraction (i.e., directly wrangling characters)?</p>
<p dir=3D"auto">I'm not finding examples of managing the printing of nume=
rals that clarifies this. So I appreciate being told what's wrong with t=
hat code, but would also welcome any information about what would be the =
correct approach.</p>
<p dir=3D"auto">Thanks!</p>
<p dir=3D"auto">On 27 Mar 2026, at 19:18, Douglas Katzman wrote:</p>
</div><div class=3D"plaintext" style=3D"white-space: normal;"><blockquote=
style=3D"margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777=
777; color: #777777;"><p dir=3D"auto">You realize your printer definition=
s rely on the Lisp *not* respecting the
<br>
text of CLHS
<br>
<<a href=3D"https://www.lispworks.com/documentation/HyperSpec/Issues/i=
ss169_w.htm" style=3D"color: #777777;">https://www.lispworks.com/document=
ation/HyperSpec/Issues/iss169_w.htm</a>> which
<br>
says that format directives respect *print-pretty* ?
<br>
So it's just a bit funny to imply that there is some SBC-specific fix (fo=
r
<br>
what one would infer is a defect) at play.</p>
<p dir=3D"auto">In file "trythis.lisp":</p>
<p dir=3D"auto">(defvar *ppd* (copy-pprint-dispatch))</p>
<p dir=3D"auto">(set-pprint-dispatch 'integer (lambda (stream obj) (forma=
t stream "[~d]"
<br>
obj)) 0 *ppd*)</p>
<p dir=3D"auto">(write 92 :pretty t :pprint-dispatch *ppd*)</p>
<p dir=3D"auto">Armed Bear Common Lisp 1.7.1</p>
<p dir=3D"auto">Java 25.0.1 Google Inc.</p>
<p dir=3D"auto">OpenJDK 64-Bit Server VM</p>
<p dir=3D"auto">Low-level initialization completed in 0.114 seconds.</p>
<p dir=3D"auto">Startup completed in 0.547 seconds.</p>
<p dir=3D"auto">Type ":help" for a list of available commands.</p>
<p dir=3D"auto">CL-USER(1): *(load "trythis.lisp")*</p>
<p dir=3D"auto">[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[\</p>
<p dir=3D"auto">[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[\</p>
<p dir=3D"auto">[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[\</p>
<p dir=3D"auto">[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[</p>
<p dir=3D"auto">#<THREAD "interpreter" {5E367A3D}>: Debugger invoke=
d on condition of type
<br>
STORAGE-CONDITION</p>
<p dir=3D"auto"> Stack overflow.</p>
<p dir=3D"auto">ECL (Embeddable Common-Lisp) 24.5.10 (git:294da20f)</p>
<p dir=3D"auto">Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya</p>
<p dir=3D"auto">Copyright (C) 1993 Giuseppe Attardi</p>
<p dir=3D"auto">Copyright (C) 2013 Juan J. Garcia-Ripoll</p>
<p dir=3D"auto">Copyright (C) 2018 Daniel Kochmanski</p>
<p dir=3D"auto">Copyright (C) 2024 Daniel Kochmanski and Marius Gerbersha=
gen</p>
<p dir=3D"auto">ECL is free software, and you are welcome to redistribute=
it</p>
<p dir=3D"auto">under certain conditions; see file 'Copyright' for detail=
s.</p>
<p dir=3D"auto">Type :h for Help.</p>
<p dir=3D"auto">Top level in: #<process TOP-LEVEL 0x7fbea6eddf00>.<=
/p>
<blockquote style=3D"margin: 0 0 5px; padding-left: 5px; border-left: 2px=
solid #777777; border-left-color: #999999; color: #999999;"><p dir=3D"au=
to">*(load "trythis.lisp")*</p>
</blockquote><p dir=3D"auto">[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\</p>
<p dir=3D"auto">[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[=
</p>
<p dir=3D"auto">Condition of type: STACK-OVERFLOW</p>
<p dir=3D"auto">BINDING-STACK overflow at size 10240. Stack can probably =
be resized.</p>
<p dir=3D"auto">Proceed with caution.</p>
</blockquote></div>
<div class=3D"markdown" style=3D"white-space: normal;">
</div>
</div>
</body>
</html>
--=_MailMate_2E8B42F3-79C1-4FE0-91F3-EB2E23497DD3_=--
--===============0136770530029308883==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============0136770530029308883==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help
--===============0136770530029308883==--