Subject: Re: Popular bug in implementation?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 25 Mar 2006 21:14:15 -0600
Newsgroups: comp.lang.lisp
Message-ID: <rsudnVl7_IyamrvZnZ2dnUVZ_sOdnZ2d@speakeasy.net>
Kaz Kylheku <kkylheku@gmail.com> wrote:
+---------------
| Mikalai wrote:
| > Back to business. Should we tell in tutorials about *PRINT-CIRCLE*, or
| > should we put it t by default?
| 
| Who is "we"?
| 
| "We" have an ANSI standard for this language, which says that
| *PRINT-CIRCLE* top level binding is initialized to NIL.
| 
| You do know that cycle detection costs ... machine cycles?
| It's expensive!
+---------------

More than that, it's often *UG-LEE*! Consider what you get in the
following example with the ANSI-mandated default:

    > (defun f () "a simple string")
    > (f)
    "a simple string"
    > (list (f) (f) (f) (f))

    ("a simple string" "a simple string" "a simple string" "a simple string")
    >

A normal-enough looking session, yes? Now turn on *PRINT-CIRCLE* and
repeat the LIST call:

    > (setf *print-circle* t)

    T
    > (list (f) (f) (f) (f))

    (#1="a simple string" #1# #1# #1#)
    > 

Is that *really* what you want to see all the time in your default REPL?!?

I speak from experience: For a few days I was debugging some code
that created some fairly-complex graphs with nodes containing lots
of up/down/self-references, and in that case *PRINT-CIRCLE* was pretty
a necessity. After only a couple of times forgetting to turn it on
when starting a session (and getting into infinite print loops!),
I just put a (SETF *PRINT-CIRCLE* T) in my "~/.cmucl-init" file.
And a few days after I was no longer working on the graph-table code,
I took it right back out again!!! Why?  Because it made too many
common REPL outputs look so *UG-LEE*!


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607