1
0
Fork 0
cl-sites/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node136.html
2023-10-25 11:23:21 +02:00

139 lines
7.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>13.1. Character Attributes</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Character Attributes">
<meta name="keywords" value="clm">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<b>Common Lisp the Language, 2nd Edition</b>
<BR> <HR><A NAME=tex2html3226 HREF="node137.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3224 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3218 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3228 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3229 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3227 HREF="node137.html"> Predicates on Characters</A>
<B>Up:</B> <A NAME=tex2html3225 HREF="node135.html"> Characters</A>
<B> Previous:</B> <A NAME=tex2html3219 HREF="node135.html"> Characters</A>
<HR> <P>
<H1><A NAME=SECTION001710000000000000000>13.1 Character Attributes</A></H1>
<P>
Every character has three attributes: code, bits, and font.
The code attribute is intended to distinguish among the printed glyphs
and formatting functions for characters. The bits attribute allows extra
flags to be associated with a character. The font attribute permits
a specification of the style of the glyphs (such as italics).
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
The treatment of character attributes in Common Lisp has not been
entirely successful. The font attribute has not been widely used,
for two reasons. First, a single integer, limited in most
implementations to 255 at most, is not an adequate, convenient, or portable
representation for a font. Second, in many applications where font
information matters it is more convenient or more efficient to represent
font information as shift codes that apply to many characters, rather than
attaching font information separately to each character.
<P>
As for the bits attribute, it was intended to support
character input from extended keyboards having extra ``shift'' keys.
This, in turn, was imagined to support the programming of a portable
EMACS-like editor in Common Lisp. (The EMACS command set
is most convenient when the keyboard has separate ``control'' and
``meta'' keys.) The bits attribute has been used in the implementation
of such editors and other interactive interfaces. However, software
that relies crucially on these extended characters will not be portable
to Common Lisp implementations that do not support them.
<P>
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=14447>&#160;</A>
and in June 1989 (MORE-CHARACTER-PROPOSAL) <A NAME=14448>&#160;</A>
to revise considerably the treatment
of characters in the language. The bits and font attributes are eliminated;
instead a character may have <i>implementation-defined attributes</i>.
The treatment of such attributes by existing character-handling functions
is carefully constrained by certain rules.
<P>
Implementations are free to
continue to support bits and font attributes, but they are
formally regarded as implementation-defined attributes.
The rules are generally consistent with the previous
treatment of the bits and font attributes.
My guess is that
the font attribute as currently defined will wither away,
but the bits attribute as defined by the first edition will
continue to be supported as a <i>de facto</i> standard extension,
because it fills a useful small purpose.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<BR><b>[Constant]</b><BR>
<tt>char-code-limit</tt><P>The value of <tt>char-code-limit</tt> is a non-negative
integer that is the upper exclusive bound on values produced
by the function <tt>char-code</tt>, which returns the <i>code</i> component
of a given character; that is, the values returned by <tt>char-code</tt>
are non-negative and strictly less than the value of
<tt>char-code-limit</tt>.
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
Common Lisp does not at present explicitly guarantee that all integers between
zero and the value of <tt>char-code-limit</tt> are valid character codes, and so
it is wise in any case for the programmer to assume that the space of
assigned character codes may be sparse.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
<BR><b>[Constant]</b><BR>
<tt>char-font-limit</tt><P>The value of <tt>char-font-limit</tt> is a non-negative
integer that is the upper exclusive bound on values produced
by the function <tt>char-font</tt>, which returns the <i>font</i> component
of a given character; that is, the values returned by <tt>char-font</tt>
are non-negative and strictly less than the value of
<tt>char-font-limit</tt>.
<P>
<hr>
<b>Implementation note:</b> No Common Lisp implementation is required to support
non-zero font attributes; if it does not, then <tt>char-font-limit</tt>
should be <tt>1</tt>.
<hr>
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=14476>&#160;</A>
to eliminate <tt>char-font-limit</tt>.
<P>
Experience has shown that numeric codes are not an especially
convenient, let alone portable, representation for font information.
A system based on typeface names, type styles, and point sizes would be much better.
(Macintosh software developers made the same discovery and have recently
converted to a new font identification scheme.)
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
<BR><b>[Constant]</b><BR>
<tt>char-bits-limit</tt><P>The value of <tt>char-bits-limit</tt> is a non-negative
integer that is the upper exclusive bound on values produced
by the function <tt>char-bits</tt>, which returns the <i>bits</i> component
of a given character; that is, the values returned by <tt>char-bits</tt>
are non-negative and strictly less than the value of
<tt>char-bits-limit</tt>. Note that the value of <tt>char-bits-limit</tt>
will be a power of 2.
<P>
<hr>
<b>Implementation note:</b> No Common Lisp implementation is required to support
non-zero bits attributes; if it does not, then <tt>char-bits-limit</tt>
should be <tt>1</tt>.
<hr>
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=14494>&#160;</A>
to eliminate <tt>char-bits-limit</tt>.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<BR> <HR><A NAME=tex2html3226 HREF="node137.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3224 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3218 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3228 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3229 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3227 HREF="node137.html"> Predicates on Characters</A>
<B>Up:</B> <A NAME=tex2html3225 HREF="node135.html"> Characters</A>
<B> Previous:</B> <A NAME=tex2html3219 HREF="node135.html"> Characters</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>