J3/06-175r1
Date: 11-may-2006
To: J3
From: Bill Long, Van Snyder
Subject: Edits for BITS
References: Feature J3-047, J3/05-188, J3/05-274r3
--------------------------------------------------------------
Following are a draft of the edits to implement the J3-047 feature, BITS
type, as amended by paper J3/05-274r3.
Note 1. < and > are used to delimit italic font. << and >> are
used to delimit bold font.
Note 2. All page and line numbers refer to j3/04-007.
EDITS
.....................................................................
[xiii] Introduction, the list of new Fortran 2008 features should
include
A BITS data type for non-numeric programming and enhanced handling of
BOZ constants.
.....................................................................
In section 1.6 Compatibility, retain paragraph 3:5-9 regarding new
intrinsic procedure names. There are new intrinsics introduced in
this proposal.
In addition, add to a section on incompatibility with Fortran 2003:
[3:10-]
This standard specifies a new intrinsic type, BITS, which will
conflict with a user defined type of the same name.
This standard specifies a new intrinsic operator, .XOR., which
will conflict with a user defined operator of the same name.
.....................................................................
[15:39] Replace the second sentence of 2.4.1.1 Intrinsic type with:
The intrinsic types are integer, real, complex, character, logical,
and bits.
.....................................................................
[16:2-3] Replace the end of the first sentence in the second
paragraph of 2.4.1.1 Intrinsic types that begins with ", and the
representation..." with:
, the representation methods for the character and logical types
(4.4.4, 4.4.5), and the number of bits for the bits type (4.4.6).
.....................................................................
[26:28+] Add a new rule to '3.2.3 Operators' to make .XOR. a
kind of :
<> .XOR.
.....................................................................
[33:5] At the end of the second paragraph of 'Section 4: Types',
replace "character, and logical." with
"character, logical, and bits."
.....................................................................
[33:19] At the end of the second sentence of '4.1.1 Set of values',
replace "character, and real." with: "character, real, and bits."
.....................................................................
[35:29] In 4.4 Intrinsic types, replace the list of non-numeric types
with:
nonnumeric types: character, logical, and bits
.....................................................................
[36:7+] Add a new type entry in 4.4 Intrinsic types, to
R403 :
<> BITS []
.....................................................................
[37:1-3] Delete R411 .
[37:4-18] Move the rest of the description of constants out of
4.4.1 Integer type to new section 4.4.6 Bits type - edits [44:17+].
.....................................................................
[37:19,22-25] Delete some of the description of boz constants (replaced
with new text in [44:17+]) and remove constraint C410 in '4.4.1 Integer
type'.
[37:20-21] Move this sentence into new 4.4.6 (see below).
.....................................................................
[44:17+] Add a new subsection, consisting of:
Firstly, the text:
"4.4.6 Bits type
The <> has a set of values composed of ordered sequences
of bits. The number of bits in the sequence is specified by the kind
type parameter, KIND, which shall be greater than or equal to
zero. The processor shall provide representation methods with kind
| type parameter values equal to every nonnegative integer less than or
equal to four times NUMERIC_STORAGE_SIZE(13.8.2.7). Additional
representation methods may be provided.
The type specifier for the bits type uses the keyword BITS.
If the kind type parameter is not specified for a bits variable, the
default kind value is NUMERIC_STORAGE_SIZE, and the type specified is
<>.
R428a <> [ _ ]
<> [ _ ]
<> [ _ ]"
Insert the text from [37:4-18] here, renumbering the Rules from
(R412, R413, R414, R415) to (R428b, R428c, R428d, R428e) and
constraints (C408, C409) to (C423a C423b).
| Insert a new rule after the text from [37:18]:
| "R428f <> [ ] ... "
Insert the text from [37:20-21] here.
Insert more text and a Note:
"If the optional kind type parameter is not specified for a boz
literal constant, the kind value is assumed from the form of the
constant. If the constant is a the kind value is
the number of characters. If the constant is an
the kind value is three times the number of
characters. If the constant is a the kind value is
four times the number of characters.
Any bits value may be represented as a , or a
concatenation of multiple s.
The digits of octal constants represent triples of bits, and the hex
digits of hexadecimal constants represent quartets of bits, according
to their numerical representations as binary integers, with leading
zero bits where needed.
If a is specified for a boz literal constant and has a
value greater than the kind assumed from the number of s or
s in the constant, the constant is padded on the left with
enough 0 bits to create a constant of kind . If the
specified has a value smaller than the kind assumed from
the number of s or s in the constant, bits on the
left are removed to create a constant of kind ."
Note 4:15a:
"Though the processor is required to provide bit kinds up to four times
NUMERIC_STORAGE_SIZE, it is expected that the actual size limit is much
larger, based on system capacity constraints. Use of BITS objects with
KIND values equal to small integer multiples of NUMERIC_STORAGE_SIZE
should result in more aggressive optimization."
[end Note]
.....................................................................
[46:20] In 4.5.1.2 Sequence type, in the sentence defining a
numeric sequence type, change "logical, or a numeric sequence type"
"logical, default bits, or a numeric sequence type".
.....................................................................
[76:5+] In '5.1.1.2 Class' in the discussion of type compatibility,
add a new paragraph:
"A scalar entity of type bits is <> with a scalar
entity of type bits, integer, real, complex, or logical if and only
if both entities have the same size expressed in bits."
.....................................................................
[76:7-9] In '5.1.1.2 Class', replace the paragraph defining TKR
compatible with:
"An entity is type, kind, and rank compatible, or <>,
with another entity if both entities have the same rank, and either
the first entity is type compatible with the second and the kind type
parameters of the first entity have the same values as corresponding
kind type parameters of the second, or the two entities are bits
compatible.
.....................................................................
[89:20-22] Delete this paragraph from '5.2.5 DATA statement',
referring to in DATA statements.
.....................................................................
[119:2] In '7.1.1.4 Level-3 expressions' replace "character
operator " with "character operator and bits
concatenation operator ".
.....................................................................
[120:2] In '7.1.1.6 Level-5 expressions' replace "the logical
operators" with "the logical and bits operators".
.....................................................................
[120:12+] In '7.1.1.6 Level-5 expressions', extend rule R721 for
to include .XOR.:
<> .XOR.
.....................................................................
[121:7+] In 'Table 7.1: Type of operands and results for intrinsic
operators', replace boxes 3-7 with (redundant headings supplied for
clarity only):
Intrinsic operator Type of Type of Type of
[]
----------------------------------------------------------------
// C C C
B B B
----------------------------------------------------------------
I I,R,Z,B L,L,L,L
.EQ. .NE. R I,R,Z,B L,L,L,L
==, /= Z I,R,Z,B L,L,L,L
B I,R,Z,B L,L,L,L
C C L
----------------------------------------------------------------
I I,R,B L,L,L
.GT.,.GE.,.LT.,.LE. R I,R,B L,L,L
>, >=, <, <= B I,R,B L,L,L
C C L
----------------------------------------------------------------
.NOT. L,B L,B
----------------------------------------------------------------
.AND.,.OR.,.XOR.,.EQV., L L L
.NEQV. B B,I B,B
I B,I B,B
.....................................................................
[121:7+] In the Note at the bottom of 'Table 7.1: Type of operands
and results for intrinsic operators', replace the first sentence
with:
"The symbols I, R, Z, C, L, and B stand for the types integer, real,
complex, character, logical, and bits respectively."
.....................................................................
[121:17-25] In '7.1.2 Intrinsic operations', replace the 5th and 6th
paragraphs beginning "A <> is an intrinsic operation for
which the is (//) and both operands are of type
character. The operands shall have the same kind type parameter. The
<> is the operator in a character
intrinsic operation.
A <> is an intrinsic operation for which
| the is .AND., .OR., .XOR., .NOT.,
| .EQV., or .NEQV. and both operands are of type logical. A <> is the operator in a logical intrinsic operation.
A <> is an intrinsic operation for which the
| is //, .AND., .OR., .XOR.,
| .NOT., .EQV., or .NEQV. and at least one operand is of type bits. A
<> is the operator in a bits intrinsic
operation.
For bits intrinsic operations where the is not
//, the two operands may be of different types or different kind type
parameters. If one operand, , is not of type bits, that operand is
converted to a value of type bits and kind type parameter
BITS_KIND(), and the new value takes the place of as an
operand. If the resulting operands have different kind type
parameters, the operand with the smaller kind type parameter is
converted to a bits value with the kind type parameter of the other
- operand before the operation is performed.
| A <> is an that
| is .EQ., .NE., .GT., .GE., .LT., .LE., ==, /=, >, >=, <, or <=. A
<> is an intrinsic operation for which
the is a relational intrinsic operator. A
<> is a relational intrinsic
operation for which both operands are of numeric type. A <> is a relational intrinsic operation
for which both operands are of type character. The kind type
parameters of the operands of a character relational intrinsic
operation shall be the same. A <>
is a relational intrinsic operation for which at least one of the
operands is of type bits.
.....................................................................
[123:24+] In '7.1.4 Type, type parameters, and shape of an
expression', add a syntax term for a bits expression:
R728a <>
C709a (R728a) shall be of type bits.
.....................................................................
[124:24] In '7.1.4.2 Type, type parameters, and shape of the result
of an expression', in item (2) for unary operators, change
"real, complex, or logical" to "real, complex, logical, or bits"
.....................................................................
[124:44+] In '7.1.4.2 Type, type parameters, and shape of the result
of an expression', add a new item in the list after item 5:
(5a) For an expression // where both operands are of type
bits, the kind type parameter of the result is the sum of the
kind type parameters of the operands. For an expression
where both operands are of type bits and is a
bits intrinsic binary operator other than //, the kind type
parameter of the expression is the maximum of the kind type
parameters of the operands. For an expression
where only one operand is of type bits and is a bits
intrinsic binary operator other than //, the kind type parameter
of the expression is the maximum of the kind type parameter of
the operand of type bits and BITS_KIND() where is the
other operand.}
.....................................................................
[125:41] In the list of a specification inquiry in '7.1.6
Specification expression', replace item (4) with:
(4) the kind inquiry functions KIND and BITS_KIND,
.....................................................................
[132:9+] Add a new subsection to '7.1.8 Evaluation of operations'
just before '7.1.8.7 Evaluation of a defined operation':
7.1.8.6a Evaluation of bits intrinsic operations
The rules given in 7.2.5 specify the interpretation of bits
intrinsic operations. Once the interpretation of an expression has
been established in accordance with those rules, the processor may
evaluate any other expression that is computationally equivalent,
provided that the integrity of parentheses in any expression is
not violated.
Note 7.23a
| For example, for the variables B1, B2, and B3 of type bits, the
processor may choose to evaluate the expression
B1 .xor. B2 .xor. B3
as
B1 .xor. (B2 .xor. B3)
[end Note]
Two expressions of type bits are computationally equivalent if their
values are equal for all possible values of their primaries.
.....................................................................
[132:18] In the second sentence of '7.2 Interpretation of operations'
replace "character, relational, and logical" with "character,
relational, logical, and bits".
.....................................................................
/EDIT NOTE TO EDITOR: FIX EXISTING EXECRABLE STYLE AT [135:1-4,9-12].
[135:22-] At the end of '7.2.3 Relational intrinsic operations',
add two new paragraphs:
"A bits relational intrinsic operation is interpreted as having the logical
value true if and only if the values of the operands satisfy the relation
specified by the operator."
"For a bits relational intrinsic operation where the operands are both of
type bits and of the same kind type parameter, and are equal if,
at each bit position, their corresponding bits are the same, or they both
have kind type parameter value of zero; otherwise they are unequal. If
and are unequal, and the leftmost unequal corresponding bit of
is 1 and is 0 then is considered to be greater than ;
otherwise is considered to be less than . If both and
are of type bits but have unequal kind type parameters, the operand with
the smaller kind type parameter is treated as if it were padded on the
left with the number of 0 bits required to make the number of bits in each
operand the same. If one of the operands is not of type bits, that
operand, , is converted to type bits with a kind type parameter of
BITS_KIND() before the operation is evaluated."
.....................................................................
/EDIT NOTE TO EDITOR: .EQV. SHOULD PRECEDE .NEQV. IN THIS TABLE.
[135:28+] In Table 7.5 in '7.2.4 Logical intrinsic operations' add
a new row following the entry for .OR.:
".XOR. Logical nonequivalence .XOR. True if either
or is true,
but not both."
.....................................................................
[136:2-] After Table 7.6 in '7.2.4 Logical intrinsic operations'
add a new paragraph:
The values for the logical intrinsic operation .XOR. are
identical to those for .NEQV. .
.....................................................................
[136:2-] At the end of section '7.2 Interpretation of operations',
add a new subsection:
"7.2.5 Bits intrinsic operations
Bit operations are used to express bitwise operations on sequences of
bits, or to concatenate such sequences. Evaluation of a bits
operation produces a result of type bits. The permitted types of
operands of the bits intrinsic operations are specified in 7.1.2.
The bits operators and their interpretation when used to form an
expression are given in Table 7.6a, where denotes the operand of
type bits to the left of the operator and denotes the operand of
| type bits to the right of the operator. If one of the operands is
not of type bits, or they are of unequal kind type, they are
converted as described in 7.1.2 before the operation is performed.
Table 7.6a Interpretation of the bits intrinsic operators
---------------------------------------------------------------------
Operator Representing Use of operator Interpretation
---------------------------------------------------------------------
// concatenation // concatenate with
.NOT. bitwise not .NOT. bitwise not of
.AND. bitwise and .AND. bitwise and of and
.OR. bitwise or .OR. bitwise or of and
.XOR. bitwise .XOR. bitwise exclusive or of
exclusive or and
.EQV. bitwise .EQV. bitwise equivalence of
equivalence and
.NEQV. bitwise .NEQV. bitwise nonequivalence
nonequivalence of and
--------------------------------------------------------------------
- The leftmost KIND() bits of the result of the bits concatenation
| operation are the value of and the rightmost KIND() bits of
| the result are the value of .
For a bits intrinsic operation other than //, the result value is computed
separately for each pair of bits at corresponding positions in each
operand. The value of each bit operation, for bits denoted and
are given in Table 7.6b.
Table 7.6b The values of bitwise operations involving bits intrinsic
operators
--------------------------------------------------------------------
.NOT. .AND. .OR. .XOR.
0 0 1 0 0 0
0 1 0 0 1 1
1 0 1 0 1 1
1 1 0 1 1 0
--------------------------------------------------------------------
| The values for the bits intrinsic operation .NEQV. are
| identical to those for .XOR. . The values for the bits
| intrinsic operation .EQV. are identical to those for
| .NOT. ( .XOR. ).
.....................................................................
[136:5+] In 'Table 7.7 Categories of operations and relative
precedence', in the column labeled "Category of operation" replace
"Logical" with "Logical or Bits" four times. In the second to last
row of the same table, replace ".EQV. or .NEQV." with ".XOR., .EQV.,
or .NEQV."
.....................................................................
[139:2] In 'Table 7.8 Type conformance for the intrinsic assignment
statement', modify the entries for integer, real, complex, and
logical, and add an entry for bits as follows:
Type of Type of
integer integer, real, complex, bits
real integer, real, complex, bits
complex integer, real, complex, bits
bits integer, real, complex, bits, logical
logical logical, bits
.....................................................................
| [139:6] In the paragraph following Table 7.8, before the last
sentence, insert a new sentence:
| "A <> is an intrinsic
assignment statement for which either or is of
| type bits."
| ***Note to editor: If the edits from 05-278r2 are taken into
| account, the new sentence becomes:
| "A <> is an intrinsic assignment
| statement for which either the assigned variable or is of type
| bits."
| .....................................................................
| [141:14-] In '7.4.1.3 Interpretation of intrinsic assignments' add
| four new paragraphs and a Note (following Note 7.39):
| "For a bits intrinsic assignment statement, the assigned variable and
| may have different types or different kind type parameters, in
| which case the value of is converted to the type and kind type
| parameter of the assigned variable according to the rules of Table
| 7.9a.
Table 7.9a: Bits conversion and the assignment statement
| Type of assigned variable Value assigned
bits BITS (, KIND = KIND())
integer INT (, KIND = KIND())
logical LOGICAL (, KIND = KIND())
real REAL (, KIND = KIND())
complex CMPLX (, KIND = KIND())
Note: The functions BITS, INT, LOGICAL, REAL, CMPLX, and KIND are the
generic functions defined in 13.7."
| Note 7.39a: Bits assignment is not always the same as the result of
the TRANSFER intrinsic, because:
(a) bits assignment operates elementally, whereas TRANSFER does not
preserve array element boundaries;
(b) for scalars, if the source is larger TRANSFER uses those bits which occur
first in memory whereas bits assignment always uses the "rightmost" bits
(according to the model for bits values), independent of the endianness of
the processor's memory addressing;
(c) if the source is smaller, TRANSFER copies it to the part of the result
which occurs first in memory address order and leaves the remaining bits of
the result processor-dependent, whereas bits assignment copies the source
to the rightmost bits and makes the remaining bits all zero.
[end Note]
| ***Note to editor: If the edits in 05-278r2 are taken into account,
| the initial paragraph and table of this edit becomes:
| "For a bits intrinsic assignment statement, the assigned variable and
| may have different types or different kind type parameters,
| in which case the value of is converted to the type and kind
| type parameter of the assigned variable according to the rules of
| Table 7.9a.
| Table 7.9a: Bits conversion and the assignment statement
| Type of the assigned variable Value assigned
| bits BITS (, KIND = KIND())
| integer INT (, KIND = KIND())
| logical LOGICAL (, KIND = KIND())
| real REAL (, KIND = KIND())
| complex CMPLX (, KIND = KIND())
| Note: The functions BITS, INT, LOGICAL, REAL, CMPLX, and KIND
| are the generic functions defined in 13.7."
.....................................................................
[143:14] In C716 in section '7.4.2 Pointer assignment' replace the
last phrase "and the corresponding kind type parameters shall be
equal" to "and the corresponding kind type parameters shall be
| equal, or and shall be bits
compatible (5.1.1.2).
.....................................................................
[144:21] In '7.4.2.1 Data pointer assignment' replace the end of the
first sentence of the 4th paragraph
"as the corresponding type parameters of , or
and shall be bits compatible
(5.1.1.2)."
.....................................................................
[226:23] In '10.6 Data edit descriptors', in item (2) of the second
numbered list, replace "numeric or logical variable" with "numeric,
bits, or logical variable"
.....................................................................
[226:29] In the paragraph immediately before '10.6.1 Numeric
editing', replace "numeric, logical" with "numeric, bits, logical"
.....................................................................
[226:31] Replace the name of subsection 10.6.1, "Numeric editing",
with "Numeric and bits editing"
.....................................................................
[226:33] In the first sentence of '10.6.1 Numeric editing', replace
"integer, real, and complex" with "integer, real, complex, and bits"
.....................................................................
[227:16 - 228:1] Remove the B, O, and Z edit descriptors from
subsubsection 10.6.1.1 Integer editing, resulting in:
10.6.1.1 Integer editing
The I and I edit descriptors indicate that the field to be
edited occupies positions, except when is zero. When is
zero, the processor selects the field width. On input, shall not
be zero. The specified input/output list item shall be of type integer
or bits. The G edit descriptor (10.6.4.4) or the B, O, or Z edit
descriptors (10.6.1.3) also may be used to edit integer data.
If the input list item is of type bits, the input field is edited as
if the input list item were of type integer and bits compatible with
the actual list item, followed by the effect of an intrinsic
assignment of the resulting integer value to the actual list item.
On input, m has no effect.
In the input field for the I edit descriptor, the character string
shall be an (R406), except for the
interpretation of blanks.
If the output list item is of type bits, its value is interpreted as a
nonnegative integer (13.3).
The output field for the I edit descriptor consists of zero or more
leading blanks followed by a minus sign if the internal value is
negative, or an optional plus sign, followed by the magnitude of the
internal value as a without leading zeros.
Note 10.8
The always consists of at least one digit.
[end Note]
The output field for the I edit descriptor is the same as for the
I edit descriptor, except that the consists of at
least digits. If necessary, sufficient leading zeros are included
to achieve the minimum of digits. The value of shall not
exceed the value of , except when is zero. If is zero and
the internal value consists of all zero bits, the output field
| consists of only blank characters, regardless of the sign control in
| effect. When and are both zero, and the internal value is
| zero, one blank character is produced.
.....................................................................
[228:5] At the end of the first paragraph in '10.6.1.2 Real and
complex editing', add a new sentence:
The B, O, and Z edit descriptors also may be used to edit real
data (10.6.1.3).
.....................................................................
[232:21-] Before '10.6.2 Logical editing' add a new subsubsection to
the Numeric editing subsection:
10.6.1.3 Bits editing
The B, B, O, O, Z, and Z edit descriptors
indicate that the field to be edited occupies positions, except
when is zero. When is zero, the processor selects the field
| width. On input, shall not be zero. The input/output
list item shall be of type bits, integer, or real. The G edit
descriptor (10.6.4.4) or the I edit descriptor (10.6.1.1) also may be
used to edit bits data.
If the input list item is not of type bits, the input field is edited
as if the input list item were of type bits and bits compatible with
the actual list item, followed by the effect of an intrinsic
assignment of the resulting bits value to the actual list item.
On input, m has no effect.
In the input field for the B, O, and Z edit descriptors the character
string shall consist of binary, octal, or hexadecimal digits (as in
| R428c, R428d, R428e) in the respective input field. The lower-case
| hexadecimal digits a through f in a hexadecimal input field are
| equivalent to the corresponding upper-case hexadecimal digits.
If the output list item is not of type bits, it is first converted to
a list item of type bits that is bits compatible with it.
The output field for the B, O, and Z descriptors consists of
zero or more leading blanks followed by the internal value in a form
identical to the digits of a binary, octal, or hexadecimal constant,
respectively, with the same value and without leading zeros.
Note 10.13a
A binary, octal, or hexadecimal constant always consists of at least
one digit or hexadecimal digit.
[end Note]
The output field for the B, O, and Z edit descriptor is
the same as for the B, O, and Z edit descriptor, except that
the or consists of at least
digits. If necessary, sufficient leading zeros are included to achieve
the minimum of digits. The value of shall not exceed the value
of , except when is zero. If is zero and the internal value
consists of all zero bits, the output field consists of only blank
characters. When and are both zero, and the internal value
consists of all zero bits, one blank character is produced.
.....................................................................
[233:23] In '10.6.4 Generalized editing', last sentence of the
first paragraph, replace "integer, logical, or character" with
| "integer, bits, logical, or character".
.....................................................................
| [234:13-] Before subsection '10.6.4.3 Generalized logical editing',
| add a new subsection:
| 10.6.4.1a Generalized bits editing
When used to specify the input/output of bits data, the G and
GE edit descriptors follow the rules for the Zw edit
descriptor (10.6.1.3), except that shall not be zero. When used to
specify the output of bits data, the G0 edit descriptor follows the
rules for the Z0 edit descriptor.
.....................................................................
[237:37] In the first sentence of the second paragraph of '10.7.6
BN and BZ editing', replace "in numeric input fields" with "in
| numeric and bits input fields".
.....................................................................
[237:42-43] Replace the first sentence of the third paragraph of
'10.7.6 BN and BZ editing' with:
The blank interpretation mode affects only numeric and bits editing
(10.6.1), generalized numeric editing (10.6.4.1), and generalized bits
editing (10.6.4.4) on input.
.....................................................................
| [239:19+] After the third paragraph of '10.9.1 List-directed input',
| which begins 'Then the next effective item is of type integer', add
| a new paragraph:
| When the next effective item is of type bits, the value on the input
record is interpreted as if a Z edit descriptor with a
suitable value of were used.
.....................................................................
| [241:10+] After the fourth paragraph of '10.9.2 List-directed output'
| that begins 'Integer output' add a new paragraph:
Bits output constants are produced with the effect of a Z edit
| descriptor.
.....................................................................
| [241:15-16] In the sixth paragraph of '10.9.2 List-directed output'
| that begins 'For numeric output', replace "numeric" with
| "numeric and bits" twice.
.....................................................................
[243:36] In the first sentence of '10.10.1.2' Namelist input values'
replace "list items of types logical, integer, and character" with
| "list items of types logical, integer, bits, and character".
.....................................................................
| [244:37+] After the fourth paragraph of '10.10.1.3 Namelist group
| object list items' that begins 'When the next effective item is
| of type integer', add a new paragraph:
When the next effective list item is of type bits, the value in the
input record is interpreted as if a Z edit descriptor with a
suitable value of