mj@cs.brown.edu (Mark Johnson) (12/19/89)
Is there an easy way to modify the lisp READ function so that it does not always convert lower case letters to upper case in symbol names? The Lisp reader is fine for a simple NLP project of mine, except for this case conversion. Reflecting on the issue as I was walking in this morning, it seemed to me that the readtable would be the logical place for the case conversion to be specified. But it seems as if they are hardwired into the reader itself. If this is so, why? Thanks, Mark Johnson
farquhar@cs.utexas.edu (Adam Farquhar) (12/20/89)
In article <23295@brunix.UUCP> mj@cs.brown.edu (Mark Johnson) writes: >Is there an easy way to modify the lisp READ function so that >it does not always convert lower case letters to upper case >in symbol names? The variable *print-case* may provide the functionality that you need. If *print-case* is set to :downcase, rather than it's default value of :upcase, all symbols will be printed out in lowercase. This only affects the printing, however, and does not alter the name of any symbols. As a colleague of mine, David Throop, recently pointed out to me, this may result in some suprising behavior when converting from strings to symbols. I.e. (setq *print-case* :downcase) => :downcase (setq x 'foo) => foo (string x) => "FOO" (format nil "~a" x) => "foo" (intern "foo") => |foo| thus (eq (intern "foo") x) => nil and (eq (intern "FOO") x) => t and (eq (intern (prin1-to-string 'foo)) 'foo) => nil This can give rise to some difficult to find bugs. I would tend to lowercase output with either string-downcase or (format t "~(~a~)"). Adam Farquhar.
gat@robotics.Jpl.Nasa.Gov (Eran Gat) (12/20/89)
In article <23295@brunix.UUCP>, mj@cs.brown.edu (Mark Johnson) writes: > Is there an easy way to modify the lisp READ function so that > it does not always convert lower case letters to upper case > in symbol names? On page 337 of Steele, step 7 of the reader algorithm specifies that all lowercase letters are converted to upper case. (I discovered this after wasting four hours trying to figure out why my tildes were being turned into c-cediles in MacIntosh Allegro CL.) The only way to get lower case letter in symbol names is to use the \ or || escapes. > Reflecting on the issue as I was walking in this morning, it seemed > to me that the readtable would be the logical place for the > case conversion to be specified. But it seems as if they are > hardwired into the reader itself. If this is so, why? Good question! Erann Gat gat@robotics.jpl.nasa.gov (818) 354-4203
cox@Franz.COM (Charles A. Cox) (12/21/89)
In article <23295@brunix.UUCP> mj@cs.brown.edu (Mark Johnson) writes:
Is there an easy way to modify the lisp READ function so that
it does not always convert lower case letters to upper case
in symbol names? The Lisp reader is fine for a simple NLP project
of mine, except for this case conversion.
You didn't specify which lisp you were using, but if you have Franz
Allegro, you can use the function `excl:set-case-mode' to change the
reader from being in the Common Lisp specified insensitive upper-case
mode to a case-sensitive mode. An example of its use is
<cl> (excl:set-case-mode :case-sensitive-lower)
Charley
--
---
Charles A. Cox, Franz Inc. 1995 University Avenue, Suite 275
Internet: cox@franz.com Berkeley, CA 94704
uucp: uunet!franz!cox Phone: (415) 548-3600 FAX: (415) 548-8253