[Nice-commit] Nice/web manual.xml,1.30,1.31
Brought to you by:
bonniot
From: <bo...@us...> - 2003-12-17 14:33:13
|
Update of /cvsroot/nice/Nice/web In directory sc8-pr-cvs1:/tmp/cvs-serv23874/web Modified Files: manual.xml Log Message: Updated section about characters, since they are not numeric types anymore. Index: manual.xml =================================================================== RCS file: /cvsroot/nice/Nice/web/manual.xml,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** manual.xml 17 Dec 2003 11:53:59 -0000 1.30 --- manual.xml 17 Dec 2003 14:33:09 -0000 1.31 *************** *** 1112,1121 **** </section> ! <section id="conversion"><title>Conversion between numeric primitive types</title> <para> The numeric primitive types are, from the largest to the smallest: ! <type>double, float, long, int, short, byte</type>, ! and <type>char</type> which is smaller than ! <type>int</type> but incomparable with <type>short</type>. Conversion from a smaller to a larger type is automatic. Conversion from a larger to a smaller type must be done explicitly, --- 1112,1119 ---- </section> ! <section id="conversion"><title>Conversion between primitive types</title> <para> The numeric primitive types are, from the largest to the smallest: ! <type>double, float, long, int, short, byte</type>. Conversion from a smaller to a larger type is automatic. Conversion from a larger to a smaller type must be done explicitly, *************** *** 1135,1138 **** --- 1133,1148 ---- </para> <para> + In most cases, characters should be treatead as abstract entities + and not as the numbers that happen to encode them. Therefore, + the <literal>char</literal> type is not a numeric type in Nice. + Operations on characters can be performed using the methods of class + <literal>java.lang.Character</literal>. + Additionally, it is possible to convert a character + <literal>c</literal> to its integer value with + <literal>int(c)</literal>, + and to convert an integer to the character it encodes with + <literal>char(i)</literal>. + </para> + <para> For instance, here is code to read characters from a <type>Reader</type>, whose *************** *** 1143,1150 **** <example><title>Converting a value of a primitive type</title> <programlisting lang="nice"> ! BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int v; ! while ((v = r.read()) != -1) { char c = char(v); ... // Do something with the character. --- 1153,1160 ---- <example><title>Converting a value of a primitive type</title> <programlisting lang="nice"> ! let reader = new BufferedReader(new InputStreamReader(System.in)); int v; ! while ((v = reader.read()) != -1) { char c = char(v); ... // Do something with the character. |