JTC1/SC22/WG14
N738
From: Frank Farance
Organization: Farance Inc.
Telephone: +1 212 486 4700
Fax: +1 212 759 1605
E-mail: frank@farance.com
Date: 1997-06-26
Document Number: WG14/N738 J11/97-101
Subject: Improved boolean wording.
1. BOOLEAN KEYWORD SIMILAR TO COMPLEX
In subclause 6.1.1, Keywords, add the keyword "bool",
"true", and "false". Append the following wording to the
end of the Semantics section:
The tokens "bool", "true", and "false" are keywords in
translation units where the header "<bool.h>" are included,
but not otherwise; if the header is included, then any use
of the tokens "bool", "true", and "false" prior to the first
inclusion results in undefined behavior.
2. ADDING BOOL AS A BASIC TYPE
In subclause 6.1.2.5, types, add after paragraph #1 the
paragraph:
An object declared as the type "bool" is large
enough to store the values "true" and "false" and
shall have values 1 and 0, respectively.
In subclause 6.1.2.5, Types, change the first sentence in
paragraph #10 from:
The type "char", ...
to
The type "bool", the type "char", ...
3. ADDING BOOL AS AN INTEGRAL TYPE
In subclause 6.1.2.5, Types, change the first sentence in
paragraph #16 from:
The type "char", ...
to
The type "bool", the type "char", ...
4. PROMOTION TO INT
In subclause 6.2.1.1, Characters and integers, change the
title to:
6.2.1.1 Boolean, characters, and integers
In subclaused 6.2.1.1, paragraph #1, change:
A "char", ...
to:
A "bool", a "char", ...
5. DEMOTION TO BOOL
In subclause 6.2.1.1, Characters and integers, add new
paragraph #3:
When a value is demoted to a "bool", the result is
"false" if the value equals 0, and "true" otherwise.
6. UNRESOLVED ISSUES
6.1 Extensions to printf/scanf
These have yet to be resolved in either the previous Boolean
proposal (currently approved for addition to the C9X draft),
or in the current proposal. A separate paper should be
written.
6.2 Making logical and relational operators Boolean
The result of these expressions is either 0 or 1. Since
there is no overloading in C (unlike C++), there is no need
for changing the resultant type of these operators.
6.3 Extending the "is*" macros to return Boolean
This is a good idea, but a separate issue from either the
previous or current Boolean proposal. A separate paper
should be written.
6.4 Boolean bit fields
The goal is to have Boolean values, stored as a single
bit in a structure. For example:
bool x:8
However, what happens with the following?
bool x:8
Getting the correct wording would be difficult, especially
considering the DRs in this area. A solution that is
workable on all systems is:
unsigned int x:1
x = (bool) value
A paper could be written to allow this, but the wording
would be tricky.
-----------------------------------------(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/N738 Page 1)8 L
()l
()l
()0(From: Frank Farance)8 L
()0(Organization: Farance Inc.)8 L
()0(Telephone: +1 212 486 4700)8 L
()0(Fax: +1 212 759 1605)8 L
()0(E-mail: frank@farance.com)8 L
()0(Date: 1997-06-26)8 L
()0(Document Number: WG14/N738 J11/97-101)8 L
()0(Subject: Improved boolean wording.)8 L
()l
()l
()0(1. BOOLEAN KEYWORD SIMILAR TO COMPLEX)8 L
()l
()0(In subclause 6.1.1, Keywords, add the keyword "bool",)8 L
()0("true", and "false". Append the following wording to the)8 L
()0(end of the Semantics section:)8 L
()l
()0(The tokens "bool", "true", and "false" are keywords in)8 L
()0(translation units where the header "<bool.h>" are included,)8 L
()0(but not otherwise; if the header is included, then any use)8 L
()0(of the tokens "bool", "true", and "false" prior to the first)8 L
()0(inclusion results in undefined behavior.)8 L
()l
()0(2. ADDING BOOL AS A BASIC TYPE)8 L
()l
()0(In subclause 6.1.2.5, types, add after paragraph #1 the)8 L
()0(paragraph:)8 L
()l
()0(An object declared as the type "bool" is large)16 L
()0(enough to store the values "true" and "false" and)16 L
()0(shall have values 1 and 0, respectively.)16 L
()l
()0(In subclause 6.1.2.5, Types, change the first sentence in)8 L
()0(paragraph #10 from:)8 L
()l
()0(The type "char", ...)16 L
()l
()0(to)8 L
()l
()0(The type "bool", the type "char", ...)16 L
()l
()0(3. ADDING BOOL AS AN INTEGRAL TYPE)8 L
()l
()0(In subclause 6.1.2.5, Types, change the first sentence in)8 L
()0(paragraph #16 from:)8 L
()l
()0(The type "char", ...)16 L
()l
()0(to)8 L
()l
()0(The type "bool", the type "char", ...)16 L
()l
()0(4. PROMOTION TO INT)8 L
()l
()0(In subclause 6.2.1.1, Characters and integers, change the)8 L
()0(title to:)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/N738 Page 2)8 L
()l
()l
()0(6.2.1.1 Boolean, characters, and integers)16 L
()l
()0(In subclaused 6.2.1.1, paragraph #1, change:)8 L
()l
()0(A "char", ...)16 L
()l
()0(to:)9 L
()l
()0(A "bool", a "char", ...)16 L
()l
()0(5. DEMOTION TO BOOL)8 L
()l
()0(In subclause 6.2.1.1, Characters and integers, add new)8 L
()0(paragraph #3:)8 L
()l
()0(When a value is demoted to a "bool", the result is)16 L
()0("false" if the value equals 0, and "true" otherwise.)16 L
()l
()0(6. UNRESOLVED ISSUES)8 L
()l
()0(6.1 Extensions to printf/scanf)8 L
()l
()0(These have yet to be resolved in either the previous Boolean)8 L
()0(proposal \(currently approved for addition to the C9X draft\),)8 L
()0(or in the current proposal. A separate paper should be)8 L
()0(written.)8 L
()l
()0(6.2 Making logical and relational operators Boolean)8 L
()l
()0(The result of these expressions is either 0 or 1. Since)8 L
()0(there is no overloading in C \(unlike C++\), there is no need)8 L
()0(for changing the resultant type of these operators.)8 L
()l
()0(6.3 Extending the "is*" macros to return Boolean)8 L
()l
()0(This is a good idea, but a separate issue from either the)8 L
()0(previous or current Boolean proposal. A separate paper)8 L
()0(should be written.)8 L
()l
()0(6.4 Boolean bit fields)8 L
()l
()0(The goal is to have Boolean values, stored as a single)8 L
()0(bit in a structure. For example:)8 L
()l
()0(bool x:8)16 L
()l
()0(However, what happens with the following?)8 L
()l
()0(bool x:8)16 L
()l
()0(Getting the correct wording would be difficult, especially)8 L
()0(considering the DRs in this area. A solution that is)8 L
()0(workable on all systems is:)8 L
()l
()0(unsigned int x:1)16 L
()l
()l
()l
()l
()l
()l
cleartomark
showpage
restore
%%EndPage: 2 2
%%Page: 3 3
save
mark
3 pagesetup
()l
()l
()0(ISO/JTC1/SC22/WG14/N738 Page 3)8 L
()l
()l
()0(x = \(bool\) value)16 L
()l
()0(A paper could be written to allow this, but the wording)8 L
()0(would be tricky.)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
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
()l
cleartomark
showpage
restore
%%EndPage: 3 3
%%Trailer
done
%%DocumentFonts: Courier
%%Pages: 3
-----------------------------------------(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