References: character printing
Edit history: 2004-07-20, Version 1 by Bruno Haible
Status: For CLiki consideration
- Problem Description:
- CLHS specifies that when the space character is printed, it prints as "#\ ". This is not what most CL implementations have traditionally done, and brings problems because spaces at the end of line are considered redundant and removed by some text editors.
- Proposal (PRINTING-SPACE:TRADITIONAL):
- Change the behavior of character printing such that invisible graphic characters such as space can be printed by name.
- Test case:
- (prin1-to-string #\space) => "#\\Space"
- Traditional CL behaviour.
- Current practice:
- (write #\Space :escape t :pretty nil) writes "#\Space" in CLISP 2.32 and CMUCL release-18e-branch. SBCL 0.8.8.20 and CLISP CVS were changed to write "#\ " instead.
- Cost to Implementors:
- Cost to Users:
- Cost of Non-Adoption:
- User confusion. Malformed Lisp code when an editor has removed a space at end of line.
- Bruno Haible's says: ANSI CL 2.1.3 and the Glossary define Space to be a graphic character. (This is unlike ISO C 99, where space is non-graphic but printable.) I'm against introducing an additional category "printable character", because that complicates the standard. I agree that 18.104.22.168 should treat the space character differently.
- Kalle Olavi Niemitalo says: There already is a category of "printing" characters, according to the Glossary.
- pinterface says: CL does define the concept of standardized character names, of which #\Space is the only graphic character present. Rather than defining a new class of character or treating #\Space specially, would it not be enough to prefer the standardized name for any graphic character which has one? (That said, #\Space is often mentioned specially in the spec's discussions of characters, what's once more?)