Subject: Calling length on a very long improper list is disastrous.

From: Jeremy Phelps <[email-masked]>
Date: Thu, 24 Nov 2022 05:52:51 -0500

I lost my Emacs session today because I accidentally called the length
function on an extremely long improper list.

But Guile prints the entire thing when it reports the error that happens
when the length function gets to the improper part of the list. It tried to
print a few million elements just to tell me which list wasn't a proper
list.

To reproduce the error should be easy:

(length

   (let loop ((result 'x)

              (n 50000000))

     (if (= n 0)

         result

         (loop (cons n result) (- n 1)))))

Emacs is more sensitive to the problem because it doesn't throw away any of
the output. It's also really bad over SSH. The above test is enough to dump
output to a local terminal for a minute or two, or to uninterruptibly tie
up an SSH session for several minutes.