Subject: bug#44155: Print integers as characters

From: Mattias Engdegård <[email-masked]>
Date: Sun, 1 Nov 2020 13:03:52 +0100

reopen 44155
stop

I don't mind the basic idea, but I'm reopening the bug since it looks like there is some unfinished business. Hope you don't mind.

> When t, print characters from integers that represent a character.

In what way does 't' suggest a character? Wouldn't something like 'character' be more suggestive?
The variable isn't named 'print-integers-as-chars'.

> When a number 16, print non-negative integers in the hexadecimal format.

Doesn't work for bignums:

(let ((integer-output-format 16))
  (print 394583945873948753948539845))

394583945873948753948539845

This must be a bug since there is no reason why bignums should be treated specially. In general we try hard not to.

Since there is a read syntax for binary and octal numbers as well, why not permit 2 and 8?
(And why not print negative numbers in the selected radix?)

And C0/C1 controls aren't printed well:

(let ((integer-output-format t))
  (print 10)
  (print 127))

?

?^?

I strongly suggest that the controls that have special escapes, like \n, use them. What to use for the rest depends on the user's preference really -- for example, 31 might be printed as 31, ?\037, #o37 or #x1f.

Whether to print 32 as ?‹SPACE› or ?\s is a matter of taste.

For that matter, the variable name should perhaps start with 'print-' like other variables that control printing. Maybe we should separate the default radix and print integers as characters? Thus, we'd have:

print-integer-radix -- 2, 8, 16, 10 or nil (which means 10)

print-integers-as-characters -- nil or t