[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
No PRINT-time case conversion switch please!
- To: EAK at MIT-MC, COMMON-LISP at SU-AI, Fahlman at CMU-20C
- Subject: No PRINT-time case conversion switch please!
- From: Kent M. Pitman <KMP at MIT-MC>
- Date: Mon, 30 Aug 1982 06:33:00 -0000
A switch that decides the case to use at PRINT time can never do the
right thing. it will work ok for expressions like:
USER INPUT SYSTEM (normal) SYSTEM (with funny flag)
X X x
x X x
but consider:
|x| |x| x
|X| X x
These can potentially be wrong. Presumably the `normal' column above
is to print out for re-read by a Maclisp style (uppercasing) reader so that
User inputs |x|
System outputs |x|
System later re-reads |x| ;win
User inputs |X|
System outputs X
System later re-reads |X| ;win
Where if you do translation to lowercase at print-time and later think your
output is re-readable acceptably by some implementation that downcases instead
of upcases, you'll find that
User inputs |x| into uppercasing system
System outputs |x|
Lowercasing system later re-reads x ;win
User inputs |X| into uppercasing system
System outputs X
Lowercasing system later re-reads x ;lose!
This is disappointing because the |...| clearly denote the user's intent that
the system not muck with the case of his input. This case actually comes up in
practice. Consider Maclisp programs like:
(defun get-input ()
(terpri)
(princ '|INPUT: |)
(read))
(defun yes? ()
(memq (readch) '(/y /Y)))
Say what you'd like to about the reasonableness of printing out symbols
instead of strings, or about using readch instead of in-char or whatever.
Those are clearly substandard coding styles, but people sometimes write
substandard code and I think it's very important that we guarantee that
Lisp READ/PRINT for simple cases like these preserve a certain amount of
semantic content especially when the user has gone to the trouble to type
his symbols with /'s or |...|'s and I don't see any way a PRINT-time decision
can do anything but risk screwing the user.
Anyone who likes to see code in a certain case can write an editor package
(or borrow mine) which upcases or downcases code respecting things vbars,
doublequotes, semicolons, slashes, etc. But I don't think common lisp should
be cluttered with any dwimish notions of automatic case conversion that work
only most of the time ...