Document Number: WG14 N609/X3J11 96-073 C9X Revision Proposal ===================== Title: Boolean as a new type Author: Frank Farance Author Affiliation: Farance Inc. Postal Address: 555 Main Street, New York, NY, 10044-0150, USA E-mail Address: frank@farance.com Telephone Number: +1 212 486 4700 Fax Number: +1 212 759 1605 Sponsor: X3J11 Date: 1996-09-13 Proposal Category: __ Editorial change/non-normative contribution __ Correction X_ New feature __ Addition to obsolescent feature list __ Addition to Future Directions __ Other (please specify) ______________________________ Area of Standard Affected: __ Environment X_ Language __ Preprocessor __ Library __ Macro/typedef/tag name __ Function __ Header Prior Art: C++ Target Audience: C programmers Related Documents (if any): Proposal Attached: X_ Yes __ No, but what's your interest? This proposal is for adding boolean as a new type, not just a macro for an existing integer type. The following problems need to be resolved with a boolean type: 1. It is a keyword, or hidden magic turned on by including a header? 2. What is its type? A new C type or an existing one? 3. What are the promotion rules? 4. What about use of "false" and "true" in the preprocessor? 5. What is the migration strategy? Answer #1: For compatibility reasons, we need to have a header that turns on this feature: "#include ". The type is "bool" with values "false" and "true". Answer #2: In previous proposals, the type "bool" was a macro (or typedef) for an existing C integral type. This has raised some issues with respect to promotion rules for certain scenarios. I propose that we make "bool" a real, separate C type. Answer #3: Promotion from "bool" to other types produces the values 0 or 1. Demotion from other types to bool follows the rules: equal to 0 ==> false, not equal to 0 ==> true. Answer #4: The macros "false" and "true" will equate to 0 and 1 respectively. Answer #5: The header "" will be used to avoid breaking existing programs. The macro __bool_true_false_are_defined will be defined when the implementation defines (as macros or keywords) the boolean type via the "#include " header. We should indicate that it is our intent to make "bool" a keyword in the next revision of the Standard. -----------------------------------------(cut here)----------------- %!PS-Adobe-2.0 %%Version: 3.15 %%DocumentFonts: (atend) %%Pages: (atend) %%EndComments %ident "@(#)lp:filter/postscript/postscript/postprint.ps 1.1" % % Version 3.15 prologue for ASCII files. % /#copies 1 store /aspectratio 1 def /font /Courier def /formsperpage 1 def /landscape false def /magnification 1 def /margin 0 def /orientation 0 def /pointsize 12 def /xoffset 0.0 def /yoffset 0.0 def /roundpage true def /useclippath true def /pagebbox [0 0 612 792] def /inch {72 mul} bind def /min {2 copy gt {exch} if pop} bind def /setup { counttomark 2 idiv {def} repeat pop landscape {/orientation 90 orientation add def} if font findfont pointsize scalefont setfont /charwidth (M) stringwidth pop def /linespace pointsize pointsize pointsize 12 eq {-0.05} {0.10} ifelse mul add neg def pagedimensions xcenter ycenter translate orientation neg rotate width 2 div neg height 2 div translate xoffset inch yoffset inch translate margin 2 div dup neg translate magnification dup aspectratio mul scale height width div 1 min dup scale 0 linespace translate } def /pagedimensions { useclippath userdict /gotpagebbox known not and { /pagebbox [clippath pathbbox newpath] def roundpage currentdict /roundpagebbox known and {roundpagebbox} if } if pagebbox aload pop 4 -1 roll exch 4 1 roll 4 copy landscape {4 2 roll} if sub /width exch def sub /height exch def add 2 div /xcenter exch def add 2 div /ycenter exch def userdict /gotpagebbox true put } def /pagesetup {/page exch def 0 0 moveto 0} bind def /L { counttomark 2 idiv {charwidth mul currentpoint exch pop moveto show} repeat linespace add dup 0 exch moveto } bind def /l {show linespace add dup 0 exch moveto} bind def /done {/lastpage where {pop lastpage} if} def %%EndProlog %%BeginSetup mark setup %%EndSetup %%Page: 1 1 save mark 1 pagesetup ()l ()l ()0(ISO/JTC1/SC22/WG14/N604 Page 1)8 L ()l ()l ()0(Document Number: WG14 N604/X3J11 96-068)28 L ()l ()l ()0(C9X Revision Proposal)32 L ()0(=====================)32 L ()l ()0(Title: Proposal to fix "ungetc" for beginning of file.)8 L ()0(Author: Frank Farance)8 L ()0(Author Affiliation: Farance Inc.)8 L ()0(Postal Address: 555 Main Street, New York, NY, 10044-0150, USA)8 L ()0(E-mail Address: frank@farance.com)8 L ()0(Telephone Number: +1 212 486 4700)8 L ()0(Fax Number: +1 212 759 1605)8 L ()0(Sponsor: X3J11)8 L ()0(Date: 1996-09-13)8 L ()0(Proposal Category:)8 L ()0(__ Editorial change/non-normative contribution)11 L ()0(X_ Correction)11 L ()0(__ New feature)11 L ()0(X_ Addition to obsolescent feature list)11 L ()0(__ Addition to Future Directions)11 L ()0(__ Other \(please specify\) ______________________________)11 L ()0(Area of Standard Affected:)8 L ()0(__ Environment)11 L ()0(__ Language)11 L ()0(__ Preprocessor)11 L ()0(X_ Library)11 L ()0(__ Macro/typedef/tag name)14 L ()0(X_ Function)14 L ()0(__ Header)14 L ()0(Prior Art:)8 L ()0(Target Audience: C programmers)8 L ()0(Related Documents \(if any\):)8 L ()0(Proposal Attached: X_ Yes __ No, but what's your interest?)8 L ()l ()0(This proposal is for making "ungetc\(\)" undefined at the)8 L ()0(beginning of a file. Currently, the Standard allows the)8 L ()0(programmer to push back a character at the beginning of a)8 L ()0(file. While this ``feature'' \(a relic from certain I/O)8 L ()0(library implementations\) is allowed, there is no practical)8 L ()0(value for pushing back a character prior to reading the)8 L ()0(first character in a file. The direct consequence of this)8 L ()0(is that properly coding a ``mark and return'' feature with)8 L ()0("ftell\(\)" and "fseek\(\)" becomes overly complex and error-)8 L ()0(prone because \(1\) "ftell\(\)" can return -1 as a *valid* file)8 L ()0(position, \(2\) the programmer must provide he/her own)8 L ()0(mechanism for saving the character when performing a ``mark)8 L ()0(and return'' in this special case, \(3\) this special case)8 L ()0(causes much non-localized behavior, e.g., the)8 L ()0(reading/parsing, the marking of position, and the returning)8 L ()0(to position functions all have interrelated design, code,)8 L ()0(and state \(!\) flags rather than being independent features.)8 L ()0(Changing this behavior would reduce the complexity of)8 L ()0(writing applications and libraries that comply with the)8 L ()0(Standard.)8 L ()l ()l ()l ()l ()l ()l cleartomark showpage restore %%EndPage: 1 1 %%Page: 2 2 save mark 2 pagesetup ()l ()l ()0(ISO/JTC1/SC22/WG14/N604 Page 2)8 L ()l ()l ()0(Current wording in "ungetc", 7.9.6.11:)8 L ()l ()0(For a binary stream, its file position indicator is)16 L ()0(decremented by each successful call to the "ungetc")16 L ()0(function; if its value was zero before a call, it is)16 L ()0(^^^^^)63 L ()0(indeterminate after the call.)16 L ()0(^^^^^^^^^^^^^^^^^^^^^^^^^^^^)16 L ()l ()0(Change the last part of the sentence to:)8 L ()l ()0(For a binary stream, its file position indicator is)16 L ()0(decremented by each successful call to the "ungetc")16 L ()0(function; if its value was zero before a call, the)16 L ()0(^^^)63 L ()0(behavior is undefined.)16 L ()0(^^^^^^^^^^^^^^^^^^^^^)16 L ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l cleartomark showpage restore %%EndPage: 2 2 %%Trailer done %%DocumentFonts: Courier %%Pages: 2 -----------------------------------------(cut here)----------------- %!PS-Adobe-2.0 %%Version: 3.15 %%DocumentFonts: (atend) %%Pages: (atend) %%EndComments %ident "@(#)lp:filter/postscript/postscript/postprint.ps 1.1" % % Version 3.15 prologue for ASCII files. % /#copies 1 store /aspectratio 1 def /font /Courier def /formsperpage 1 def /landscape false def /magnification 1 def /margin 0 def /orientation 0 def /pointsize 12 def /xoffset 0.0 def /yoffset 0.0 def /roundpage true def /useclippath true def /pagebbox [0 0 612 792] def /inch {72 mul} bind def /min {2 copy gt {exch} if pop} bind def /setup { counttomark 2 idiv {def} repeat pop landscape {/orientation 90 orientation add def} if font findfont pointsize scalefont setfont /charwidth (M) stringwidth pop def /linespace pointsize pointsize pointsize 12 eq {-0.05} {0.10} ifelse mul add neg def pagedimensions xcenter ycenter translate orientation neg rotate width 2 div neg height 2 div translate xoffset inch yoffset inch translate margin 2 div dup neg translate magnification dup aspectratio mul scale height width div 1 min dup scale 0 linespace translate } def /pagedimensions { useclippath userdict /gotpagebbox known not and { /pagebbox [clippath pathbbox newpath] def roundpage currentdict /roundpagebbox known and {roundpagebbox} if } if pagebbox aload pop 4 -1 roll exch 4 1 roll 4 copy landscape {4 2 roll} if sub /width exch def sub /height exch def add 2 div /xcenter exch def add 2 div /ycenter exch def userdict /gotpagebbox true put } def /pagesetup {/page exch def 0 0 moveto 0} bind def /L { counttomark 2 idiv {charwidth mul currentpoint exch pop moveto show} repeat linespace add dup 0 exch moveto } bind def /l {show linespace add dup 0 exch moveto} bind def /done {/lastpage where {pop lastpage} if} def %%EndProlog %%BeginSetup mark setup %%EndSetup %%Page: 1 1 save mark 1 pagesetup ()l ()l ()0(ISO/JTC1/SC22/WG14/N606 Page 1)8 L ()l ()l ()0(Document Number: WG14 N606/X3J11 96-070)28 L ()l ()l ()0(C9X Revision Proposal)32 L ()0(=====================)32 L ()l ()0(Title: Extended integers promotion rules)8 L ()0(Author: Frank Farance)8 L ()0(Author Affiliation: Farance Inc.)8 L ()0(Postal Address: 555 Main Street, New York, NY, 10044-0150, USA)8 L ()0(E-mail Address: frank@farance.com)8 L ()0(Telephone Number: +1 212 486 4700)8 L ()0(Fax Number: +1 212 759 1605)8 L ()0(Sponsor: X3J11)8 L ()0(Date: 1996-09-13)8 L ()0(Proposal Category:)8 L ()0(__ Editorial change/non-normative contribution)11 L ()0(__ Correction)11 L ()0(X_ New feature)11 L ()0(__ Addition to obsolescent feature list)11 L ()0(__ Addition to Future Directions)11 L ()0(__ Other \(please specify\) ______________________________)11 L ()0(Area of Standard Affected:)8 L ()0(__ Environment)11 L ()0(X_ Language)11 L ()0(__ Preprocessor)11 L ()0(__ Library)11 L ()0(__ Macro/typedef/tag name)14 L ()0(__ Function)14 L ()0(__ Header)14 L ()0(Prior Art: "" and "long long" proposals.)8 L ()0(Target Audience: C programmers)8 L ()0(Related Documents \(if any\):)8 L ()0(Proposal Attached: X_ Yes __ No, but what's your interest?)8 L ()l ()0(With the inclusion of the "" proposal, it is)8 L ()0(possible to provide more numeric types than C's integral)8 L ()0(types: "char", "short", "int", "long", and \(recently\) "long)8 L ()0(long". For example, an implementation might provide 8-bit)8 L ()0(\("char"\), 16-bit \("short"\), 32-bit \("int" and "long"\),)8 L ()0(48-bit \(no corresponding C type\), 64-bit \("long long"\), and)8 L ()0(128-bit \(no corresponding C type\). The "")8 L ()0(proposal gives access to this compiler ``magic'' tokens via)8 L ()0(macros defined in "". This proposal simplifies)8 L ()0(the promotion rules while allowing as many integral types as)8 L ()0(the implementor desires.)8 L ()l ()0(PROPOSED WORDING CHANGES)8 L ()l ()0(In subclause 6.2.1.5, Usual arithmetic conversions, replace)8 L ()0(the text staring with ``If either operand has type "unsigned)8 L ()0(long int" ...'' and ending with ``Otherwise, both operands)8 L ()0(have type "int".'' with the following text:)8 L ()l ()0(The signedness \(footnote 1\) and precision \(footnote)16 L ()0(2\) is determined for both operands. Operands with)16 L ()l ()l ()l ()l ()l cleartomark showpage restore %%EndPage: 1 1 %%Page: 2 2 save mark 2 pagesetup ()l ()l ()0(ISO/JTC1/SC22/WG14/N606 Page 2)8 L ()l ()l ()0(precision less than "int" are promoted to "int" if)16 L ()0(the operand is signed or to "unsigned int" if the)16 L ()0(operand is unsigned. The type of the result is the)16 L ()0(type of the operand with the larger precision. For)16 L ()0(operands with the same precision, but differing)16 L ()0(types, the C types shall be ordered from largest to)16 L ()0(smallest: signed and unsigned "long long", signed)16 L ()0(and unsigned "long", signed and unsigned "int". The)16 L ()0(result shall be unsigned if the operands differ in)16 L ()0(signedness, otherwise the result shall have)16 L ()0(signedness of the operands.)16 L ()l ()0(Footnote #1: The signedness is either signed or)16 L ()0(unsigned.)16 L ()l ()0(Footnote #2: Precision is measured in bits available)16 L ()0(for storage. For example, both "unsigned int" and)16 L ()0("int" have the same number of bits available for)16 L ()0(storage, but their range of values differs.)16 L ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l cleartomark showpage restore %%EndPage: 2 2 %%Trailer done %%DocumentFonts: Courier %%Pages: 2 -----------------------------------------(cut here)----------------- %!PS-Adobe-2.0 %%Version: 3.15 %%DocumentFonts: (atend) %%Pages: (atend) %%EndComments %ident "@(#)lp:filter/postscript/postscript/postprint.ps 1.1" % % Version 3.15 prologue for ASCII files. % /#copies 1 store /aspectratio 1 def /font /Courier def /formsperpage 1 def /landscape false def /magnification 1 def /margin 0 def /orientation 0 def /pointsize 12 def /xoffset 0.0 def /yoffset 0.0 def /roundpage true def /useclippath true def /pagebbox [0 0 612 792] def /inch {72 mul} bind def /min {2 copy gt {exch} if pop} bind def /setup { counttomark 2 idiv {def} repeat pop landscape {/orientation 90 orientation add def} if font findfont pointsize scalefont setfont /charwidth (M) stringwidth pop def /linespace pointsize pointsize pointsize 12 eq {-0.05} {0.10} ifelse mul add neg def pagedimensions xcenter ycenter translate orientation neg rotate width 2 div neg height 2 div translate xoffset inch yoffset inch translate margin 2 div dup neg translate magnification dup aspectratio mul scale height width div 1 min dup scale 0 linespace translate } def /pagedimensions { useclippath userdict /gotpagebbox known not and { /pagebbox [clippath pathbbox newpath] def roundpage currentdict /roundpagebbox known and {roundpagebbox} if } if pagebbox aload pop 4 -1 roll exch 4 1 roll 4 copy landscape {4 2 roll} if sub /width exch def sub /height exch def add 2 div /xcenter exch def add 2 div /ycenter exch def userdict /gotpagebbox true put } def /pagesetup {/page exch def 0 0 moveto 0} bind def /L { counttomark 2 idiv {charwidth mul currentpoint exch pop moveto show} repeat linespace add dup 0 exch moveto } bind def /l {show linespace add dup 0 exch moveto} bind def /done {/lastpage where {pop lastpage} if} def %%EndProlog %%BeginSetup mark setup %%EndSetup %%Page: 1 1 save mark 1 pagesetup ()l ()l ()0(ISO/JTC1/SC22/WG14/N609 Page 1)8 L ()l ()l ()0(Document Number: WG14 N609/X3J11 96-073)28 L ()l ()l ()0(C9X Revision Proposal)32 L ()0(=====================)32 L ()l ()0(Title: Boolean as a new type)8 L ()0(Author: Frank Farance)8 L ()0(Author Affiliation: Farance Inc.)8 L ()0(Postal Address: 555 Main Street, New York, NY, 10044-0150, USA)8 L ()0(E-mail Address: frank@farance.com)8 L ()0(Telephone Number: +1 212 486 4700)8 L ()0(Fax Number: +1 212 759 1605)8 L ()0(Sponsor: X3J11)8 L ()0(Date: 1996-09-13)8 L ()0(Proposal Category:)8 L ()0(__ Editorial change/non-normative contribution)11 L ()0(__ Correction)11 L ()0(X_ New feature)11 L ()0(__ Addition to obsolescent feature list)11 L ()0(__ Addition to Future Directions)11 L ()0(__ Other \(please specify\) ______________________________)11 L ()0(Area of Standard Affected:)8 L ()0(__ Environment)11 L ()0(X_ Language)11 L ()0(__ Preprocessor)11 L ()0(__ Library)11 L ()0(__ Macro/typedef/tag name)14 L ()0(__ Function)14 L ()0(__ Header)14 L ()0(Prior Art: C++)8 L ()0(Target Audience: C programmers)8 L ()0(Related Documents \(if any\):)8 L ()0(Proposal Attached: X_ Yes __ No, but what's your interest?)8 L ()l ()0(This proposal is for adding boolean as a new type, not just)8 L ()0(a macro for an existing integer type. The following)8 L ()0(problems need to be resolved with a boolean type:)8 L ()l ()0(1. It is a keyword, or hidden magic turned on by)16 L ()0(including a header?)16 L ()l ()0(2. What is its type? A new C type or an existing)16 L ()0(one?)16 L ()l ()0(3. What are the promotion rules?)16 L ()l ()0(4. What about use of "false" and "true" in the)16 L ()0(preprocessor?)16 L ()l ()0(5. What is the migration strategy?)16 L ()l ()0(Answer #1: For compatibility reasons, we need to have a)8 L ()0(header that turns on this feature: "#include ". The)8 L ()0(type is "bool" with values "false" and "true".)8 L ()l ()l ()l ()l ()l ()l cleartomark showpage restore %%EndPage: 1 1 %%Page: 2 2 save mark 2 pagesetup ()l ()l ()0(ISO/JTC1/SC22/WG14/N609 Page 2)8 L ()l ()l ()0(Answer #2: In previous proposals, the type "bool" was a)8 L ()0(macro \(or typedef\) for an existing C integral type. This)8 L ()0(has raised some issues with respect to promotion rules for)8 L ()0(certain scenarios. I propose that we make "bool" a real,)8 L ()0(separate C type.)8 L ()l ()0(Answer #3: Promotion from "bool" to other types produces the)8 L ()0(values 0 or 1. Demotion from other types to bool follows)8 L ()0(the rules: equal to 0 ==> false, not equal to 0 ==> true.)8 L ()l ()0(Answer #4: The macros "false" and "true" will equate to 0)8 L ()0(and 1 respectively.)8 L ()l ()0(Answer #5: The header "" will be used to avoid)8 L ()0(breaking existing programs. The macro)8 L ()l ()0(__bool_true_false_are_defined)16 L ()l ()0(will be defined when the implementation defines \(as macros)8 L ()0(or keywords\) the boolean type via the "#include ")8 L ()0(header. We should indicate that it is our intent to make)8 L ()0("bool" a keyword in the next revision of the Standard.)8 L ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l ()l cleartomark showpage restore %%EndPage: 2 2 %%Trailer done %%DocumentFonts: Courier %%Pages: 2 -----------------------------------------(cut here)----------------- -------------------------------------------------------------------- Frank Farance, Farance Inc. E-mail: frank@farance.com Telephone: +1 212 486 4700 FAX: +1 212 759 1605 ISO JTC1/SC22/WG14 & ANSI X3J11 (C Programming Language) Project Editor