349 lines
23 KiB
HTML
349 lines
23 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Issue READ-CASE-SENSITIVITY Writeup</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="../Issues/iss285_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss286.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss287_w.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss285_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss286.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss287_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue READ-CASE-SENSITIVITY Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> passed, as amended, Jun 89 X3J13<P>
|
|
<P>
|
|
<B>Issue:</B> <A HREF="iss286.htm">READ-CASE-SENSITIVITY</A><P>
|
|
<B>Forum:</B> Cleanup<P>
|
|
<B>References:</B> CLtL p 334 ff: What the Read Function Accepts,<P>
|
|
especially p 337, step 8, point 1.<P>
|
|
CLtL p 360 ff: The Readtable<P>
|
|
<A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>COPY-READTABLE</B></A> (CLtL, p 361)<P>
|
|
<A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> (CLtL, p 372)<P>
|
|
<P>
|
|
<B>Category:</B> ADDITION/CHANGE<P>
|
|
<P>
|
|
<B>Edit history:</B> Version 1, 15-Feb-89, by Dalton<P>
|
|
Version 2, 23-Mar-89, by Dalton,<P>
|
|
(completely new proposal after comments from<P>
|
|
Pitman, Gray, Masinter, <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>and</B></A> R.Tobin@uk.ac.<A REL=DEFINITION HREF="../Body/f_ed.htm#ed"><B>ed</B></A>)<P>
|
|
Version 3, 16-Jun-89, by Dalton<P>
|
|
(very minor changes in presentation<P>
|
|
<A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>and</B></A> <A REL=DEFINITION HREF="../Body/f_everyc.htm#some"><B>some</B></A> additions to <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>the</B></A> discussion)<P>
|
|
Version 4, 22-Jun-89, by Dalton<P>
|
|
(removal of <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>the</B></A> <A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A> proposal <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>and</B></A> a different<P>
|
|
specification for :INVERT after discussion with Moon)<P>
|
|
Version 5, 23-Jun-89, by Dalton<P>
|
|
(minor revisions in presentation <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>and</B></A> better test <A REL=DEFINITION HREF="../Body/m_case_.htm#case"><B>case</B></A>,<P>
|
|
as suggested by Pitman; also fixed <A REL=DEFINITION HREF="../Body/f_everyc.htm#some"><B>some</B></A> errors)<P>
|
|
Version 6, 24-Jun-89, by Dalton (small correction)<P>
|
|
Version 7, 2-Jul-89, by Masinter (as amended, Jun89X3J13)<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
The Common Lisp reader always converts unescaped constituent<P>
|
|
characters to upper case. (See CLtL, p 337, step 8, point 1.)<P>
|
|
This behavior is not always desirable.<P>
|
|
<P>
|
|
1. Lisp applications often use the Lisp reader to read their data.<P>
|
|
This is often significantly easier than writing input routines<P>
|
|
from scratch, especially if the input can be structured as lists.<P>
|
|
However, certain applications want to make use of case distinctions,<P>
|
|
and Common Lisp makes this unreasonably difficult. (You must define<P>
|
|
every letter as a read macro and have the macro function read the<P>
|
|
rest of the symbol, or else you must write a reader from scratch.)<P>
|
|
<P>
|
|
2. Some programming languages distinguish between upper and lower<P>
|
|
case in identifiers, and useful conventions are often built around<P>
|
|
such distinctions. For example, in C, constants are often written<P>
|
|
in upper case and variables in lower. In Mesa(?) and Smalltalk(?),<P>
|
|
a capital letter is used to indicate the beginning of a new word<P>
|
|
in identifiers made up of several words. In Edinburgh Prolog,<P>
|
|
variables begin with upper-case letters and constant symbols do<P>
|
|
not. The case-insensitivity of the Common Lisp reader makes<P>
|
|
it difficult to use conventions of this sort.<P>
|
|
<P>
|
|
Proposal (<A HREF="iss286.htm">READ-CASE-SENSITIVITY:READTABLE-KEYWORDS</A>)<P>
|
|
<P>
|
|
Define a new settable function, (<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> <readtable>) to<P>
|
|
control the reader's interpretation of case. The following values<P>
|
|
may be given: :UPCASE, :DOWNCASE, :PRESERVE, and :INVERT.<P>
|
|
<P>
|
|
When the value is :UPCASE, unescaped constituent characters<P>
|
|
are converted to upper-case, as specified by CLtL on page 337.<P>
|
|
<P>
|
|
When the value is :DOWNCASE, unescaped constituent characters<P>
|
|
are converted to lower-case.<P>
|
|
<P>
|
|
When the value is :PRESERVE, the case of all characters remains<P>
|
|
unchanged.<P>
|
|
<P>
|
|
When the value is :INVERT, then if all of the unescaped letters<P>
|
|
in the extended token are of the same case, those (unescaped)<P>
|
|
letters are converted to the opposite case.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>COPY-READTABLE</B></A> copies the setting of <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A>. The value of<P>
|
|
<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> for the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> is :UPCASE.<P>
|
|
<P>
|
|
The <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> of <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*READTABLE*</B></A> also has significance when printing<P>
|
|
The case in which letters are printed, when vertical-bar syntax is not<P>
|
|
used, is determined as follows:<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :UPCASE, upper-case letters are printed<P>
|
|
in the case specified by <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A>, and lower-case letters<P>
|
|
are printed in their own case.<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :DOWNCASE, lower-case letters are printed<P>
|
|
in the case specified by <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A>, and upper-case letters<P>
|
|
are printed in their own case.<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :PRESERVE, all letters are printed in their<P>
|
|
own case.<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :INVERT, the case of all letters in single-<P>
|
|
case symbol names is inverted. Mixed-case symbol names are printed<P>
|
|
as-is.<P>
|
|
<P>
|
|
The rules for escaping letters in symbol names are also affected by<P>
|
|
the <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A>. If <A REL=DEFINITION HREF="../Body/v_pr_esc.htm#STprint-escapeST"><B>*PRINT-ESCAPE*</B></A> is true, letters are escaped<P>
|
|
as follows:<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :UPCASE, all lower-case letters must be<P>
|
|
escaped.<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :DOWNCASE, all upper-case letters must be<P>
|
|
escaped.<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :PRESERVE, no letters need be escaped.<P>
|
|
<P>
|
|
When <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> is :INVERT, no letters need be escaped.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
There are a number of different ways to achieve case-sensitivity.<P>
|
|
This proposal is fairly simple but provides all of the functionality<P>
|
|
that one could reasonably expect.<P>
|
|
<P>
|
|
By using a property of the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>, we avoid introducing a new<P>
|
|
special variable. Any code that wishes to control all of the<P>
|
|
reader's parameters already takes <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*READTABLE*</B></A> into account. A new<P>
|
|
special variable would <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> such code to change.<P>
|
|
<P>
|
|
:DOWNCASE is included for symmetry with :UPCASE. <P>
|
|
<P>
|
|
:INVERT is included so that case conventions can be used in Common<P>
|
|
Lisp code without requiring that the names of symbols in the "LISP"<P>
|
|
package be written in upper case. (Opinions vary as to whether is<P>
|
|
is advisable to use such conventions, but this proposal leaves that<P>
|
|
choice to the user.)<P>
|
|
<P>
|
|
:INVERT has an effect only for single-case names so that mixed-<P>
|
|
case names can be interpreted in a more straightforward way.<P>
|
|
<P>
|
|
In order to avoid complex interactions between the case setting of<P>
|
|
the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> and <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A>, this proposal specifies a<P>
|
|
significance for <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> only when the case setting is :UPCASE<P>
|
|
or :DOWNCASE. The meaning of <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> when the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A><P>
|
|
setting is :DOWNCASE was chosen for its simplicity and for symmetry<P>
|
|
with :UPCASE while still being useful.<P>
|
|
<P>
|
|
<B>Test Cases:<P>
|
|
</B><P>
|
|
;;; Test 1 -- reading<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>defun</B></A> test1 ()<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>let</B></A> ((<A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*readtable*</B></A> (<A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>copy-readtable</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>nil</B></A>)))<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>format</B></A> t "READTABLE-CASE Input Symbol-name~<P>
|
|
~%-----------------------------------~<P>
|
|
~%")<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>dolist</B></A> (<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A> '(:upcase :downcase :preserve :invert))<P>
|
|
(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> (<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A> <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*readtable*</B></A>) <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A>)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>dolist</B></A> (input '("ZEBRA" "Zebra" "zebra"))<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>format</B></A> t "~&:~A~16T~A~24T~A"<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-upcase"><B>string-upcase</B></A> <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A>)<P>
|
|
input<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_symb_2.htm#symbol-name"><B>symbol-name</B></A> (<A REL=DEFINITION HREF="../Body/f_rd_fro.htm#read-from-string"><B>read-from-string</B></A> input)))))))<P>
|
|
<P>
|
|
The output from (TEST1) should be as follows:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> Input Symbol-name<P>
|
|
-----------------------------------<P>
|
|
:UPCASE ZEBRA ZEBRA<P>
|
|
:UPCASE Zebra ZEBRA<P>
|
|
:UPCASE zebra ZEBRA<P>
|
|
:DOWNCASE ZEBRA zebra<P>
|
|
:DOWNCASE Zebra zebra<P>
|
|
:DOWNCASE zebra zebra<P>
|
|
:PRESERVE ZEBRA ZEBRA<P>
|
|
:PRESERVE Zebra Zebra<P>
|
|
:PRESERVE zebra zebra<P>
|
|
:INVERT ZEBRA zebra<P>
|
|
:INVERT Zebra Zebra<P>
|
|
:INVERT zebra ZEBRA<P>
|
|
<P>
|
|
;;; Test 2 -- printing<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>defun</B></A> test2 ()<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>let</B></A> ((<A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*readtable*</B></A> (<A REL=DEFINITION HREF="../Body/f_cp_rdt.htm#copy-readtable"><B>copy-readtable</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>nil</B></A>))<P>
|
|
(<A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*print-case*</B></A> <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*print-case*</B></A>))<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>format</B></A> t "READTABLE-CASE <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> Symbol-name Output~<P>
|
|
~%--------------------------------------------------~<P>
|
|
~%")<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>dolist</B></A> (<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A> '(:upcase :downcase :preserve :invert))<P>
|
|
(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> (<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A> <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*readtable*</B></A>) <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A>)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>dolist</B></A> (print-case '(:upcase :downcase :capitalize))<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>dolist</B></A> (<A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>symbol</B></A> '(|ZEBRA| |Zebra| |zebra|))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_setq.htm#setq"><B>setq</B></A> <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*print-case*</B></A> print-case)<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_format.htm#format"><B>format</B></A> t "~&:~A~15T:~A~29T~A~42T~A"<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-upcase"><B>string-upcase</B></A> <A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>readtable-case</B></A>)<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_stg_up.htm#string-upcase"><B>string-upcase</B></A> print-case)<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_symb_2.htm#symbol-name"><B>symbol-name</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>symbol</B></A>)<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_wr_to_.htm#prin1-to-string"><B>prin1-to-string</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>symbol</B></A>)))))))<P>
|
|
<P>
|
|
The output from (TEST2) should be as follows:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_rdtabl.htm#readtable-case"><B>READTABLE-CASE</B></A> <A REL=DEFINITION HREF="../Body/v_pr_cas.htm#STprint-caseST"><B>*PRINT-CASE*</B></A> Symbol-name Output<P>
|
|
--------------------------------------------------<P>
|
|
:UPCASE :UPCASE ZEBRA ZEBRA<P>
|
|
:UPCASE :UPCASE Zebra |Zebra|<P>
|
|
:UPCASE :UPCASE zebra |zebra|<P>
|
|
:UPCASE :DOWNCASE ZEBRA zebra<P>
|
|
:UPCASE :DOWNCASE Zebra |Zebra|<P>
|
|
:UPCASE :DOWNCASE zebra |zebra|<P>
|
|
:UPCASE :CAPITALIZE ZEBRA Zebra<P>
|
|
:UPCASE :CAPITALIZE Zebra |Zebra|<P>
|
|
:UPCASE :CAPITALIZE zebra |zebra|<P>
|
|
:DOWNCASE :UPCASE ZEBRA |ZEBRA|<P>
|
|
:DOWNCASE :UPCASE Zebra |Zebra|<P>
|
|
:DOWNCASE :UPCASE zebra ZEBRA<P>
|
|
:DOWNCASE :DOWNCASE ZEBRA |ZEBRA|<P>
|
|
:DOWNCASE :DOWNCASE Zebra |Zebra|<P>
|
|
:DOWNCASE :DOWNCASE zebra zebra<P>
|
|
:DOWNCASE :CAPITALIZE ZEBRA |ZEBRA|<P>
|
|
:DOWNCASE :CAPITALIZE Zebra |Zebra|<P>
|
|
:DOWNCASE :CAPITALIZE zebra Zebra<P>
|
|
:PRESERVE :UPCASE ZEBRA ZEBRA<P>
|
|
:PRESERVE :UPCASE Zebra Zebra<P>
|
|
:PRESERVE :UPCASE zebra zebra<P>
|
|
:PRESERVE :DOWNCASE ZEBRA ZEBRA<P>
|
|
:PRESERVE :DOWNCASE Zebra Zebra<P>
|
|
:PRESERVE :DOWNCASE zebra zebra<P>
|
|
:PRESERVE :CAPITALIZE ZEBRA ZEBRA<P>
|
|
:PRESERVE :CAPITALIZE Zebra Zebra<P>
|
|
:PRESERVE :CAPITALIZE zebra zebra<P>
|
|
:INVERT :UPCASE ZEBRA zebra<P>
|
|
:INVERT :UPCASE Zebra Zebra<P>
|
|
:INVERT :UPCASE zebra ZEBRA<P>
|
|
:INVERT :DOWNCASE ZEBRA zebra<P>
|
|
:INVERT :DOWNCASE Zebra Zebra<P>
|
|
:INVERT :DOWNCASE zebra ZEBRA<P>
|
|
:INVERT :CAPITALIZE ZEBRA zebra<P>
|
|
:INVERT :CAPITALIZE Zebra Zebra<P>
|
|
:INVERT :CAPITALIZE zebra ZEBRA<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
While there may not be any current implementation that supports<P>
|
|
exactly this proposal, several implementations <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> some means<P>
|
|
for changing case sensitivity.<P>
|
|
<P>
|
|
Franz Inc's ExCL has a function, EXCL:SET-CASE-MODE, that sets both<P>
|
|
the "preferred case" (the case of characters in the print names of<P>
|
|
<A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> symbols such as <A REL=DEFINITION HREF="../Body/f_car_c.htm#car"><B>CAR</B></A>) and whether or not the reader is case-<P>
|
|
sensitive.<P>
|
|
<P>
|
|
In Symbolics Common Lisp, the function SET-CHARACTER-TRANSLATION<P>
|
|
can be used to make the translation of a letter be that same letter,<P>
|
|
thus achieving case-sensitivity.<P>
|
|
<P>
|
|
Xerox Medley has a function for setting a <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> flag that<P>
|
|
determines case sensitivity.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Fairly small. The reader will be slightly slower and readtables<P>
|
|
will be slightly more complex.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
Slight. Programmers must already take into account the possibility<P>
|
|
that <A REL=DEFINITION HREF="../Body/v_rdtabl.htm#STreadtableST"><B>*READTABLE*</B></A> will be a non-standard <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>. Case-sensitivity<P>
|
|
is no worse than character macros in this respect.<P>
|
|
<P>
|
|
<B>Cost of Non-Adoption:<P>
|
|
</B><P>
|
|
Applications that want to read mixed-case expressions will not<P>
|
|
be able to use the Common Lisp reader to do so (except, perhaps,<P>
|
|
by tortuous use of read macros).<P>
|
|
<P>
|
|
Programming styles that rely on case distinctions (without escape<P>
|
|
characters) will effectively be impossible in Common Lisp.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Applications will be able to read mixed-case expressions.<P>
|
|
<P>
|
|
Programmers will be able to make use of case distinctions.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
For the proposal: <P>
|
|
<P>
|
|
The language will have greater symmetry, because it will be<P>
|
|
possible to control the treatment of case on both input and output<P>
|
|
instead of only on output (as is now the case).<P>
|
|
<P>
|
|
The language will look less old-fashioned.<P>
|
|
<P>
|
|
Against the proposal:<P>
|
|
<P>
|
|
It is, perhaps, inconsistent to control case-sensitivity by a<P>
|
|
<A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> operation when other aspects of the reader, such as the<P>
|
|
input base and the default float format (not to mention the<P>
|
|
package), are controlled by special variables. However, it can be<P>
|
|
argued that character-level syntax is determined chiefly by the<P>
|
|
<A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>. Case-sensitivity can be seen as analogous to character<P>
|
|
macros in this respect.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Dalton supports the proposal READTABLE-KEYWORDS.<P>
|
|
<P>
|
|
Version 1 of the proposal suggested a new global variable rather<P>
|
|
than a property of the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A>. Pitman was strongly opposed to<P>
|
|
that proposal and gave convincing arguments that it should be<P>
|
|
dropped. Gray suggested that the <A REL=DEFINITION HREF="../Body/t_rdtabl.htm#readtable"><B>readtable</B></A> property should be a<P>
|
|
function. Versions 2 and 3 included a <A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A> proposal as well<P>
|
|
as the <A REL=DEFINITION HREF="../Body/t_kwd.htm#keyword"><B>KEYWORD</B></A> one. But at the March 1989 X3J13 meeting it was<P>
|
|
felt that there should be only a single proposal and, since<P>
|
|
opinion seemed to favor the <A REL=DEFINITION HREF="../Body/t_kwd.htm#keyword"><B>KEYWORD</B></A> proposal, the <A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A><P>
|
|
proposal was dropped.<P>
|
|
<P>
|
|
In earlier versions of the proposal, :INVERT worked a letter at<P>
|
|
a time (rather than operating on extended tokens) so that, for<P>
|
|
example, Zebra read as zEBRA. However, the purpose of :INVERT<P>
|
|
is to let the programmer get the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> internal case (ie,<P>
|
|
upper case) by writing lower case rather than upper. This<P>
|
|
matters when referring to single-case symbols such as those<P>
|
|
in the LISP package. But, in most cases, mixed-case identifiers<P>
|
|
will already have the right case. For example, one would use<P>
|
|
TheNextWindow to get TheNextWindow, not tHEnEXTwINDOW.<P>
|
|
<P>
|
|
</PRE>
|
|
<HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|