P. 1
Draft ANSI C Rationale

Draft ANSI C Rationale

|Views: 5,344|Likes:
Published by inExcelsisDeo
Rationale for Draft Proposed National Standard for Information Systems - Programming Language C (ANSI X3J11/88-151) (Nov 18, 1988)
Rationale for Draft Proposed National Standard for Information Systems - Programming Language C (ANSI X3J11/88-151) (Nov 18, 1988)

More info:

Published by: inExcelsisDeo on Jun 11, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less



Certain syntactic forms of assignment operators have been discontinued, and others
tightened up (see §3.1.5).
The storage assignment need not take place until the next sequence point. (A
restriction in earlier drafts that the storage take place before the value of the ex-
pression is used has been removed.) As a consequence, a straightforward syntactic
test for ambiguous expressions can be stated. Some definitions: A side effect is a
storage to any data object, or a read of a volatile object. An ambiguous expression is
one whose value depends upon the order in which side effects are evaluated. A pure
function is one with no side effects; an impure function is any other. A sequenced
expression is one whose major operator defines a sequence point: comma, &&, ||,
or conditional operator; an unsequenced expression is any other. We can then say
that an unsequenced expression is ambiguous if more than one operand invokes any
impure function, or if more than one operand contains an lvalue referencing the
same object and one or more operands specify a side-effect to that object. Further,
any expression containing an ambiguous expression is ambiguous.
The optimization rules for factoring out assignments can also be stated. Let
X(i,S) be an expression which contains no impure functions or sequenced operators,
and suppose that X contains a storage S(i) to i. The storage expressions, and
related expressions, are
















i = y



i op= y i op y

i op y

Then X(i,S) can be replaced by either

(T = i, i = Snew(i), X(T,Sval))


(T = X(i,Sval), i = Snew(i), T)

provided that neither i nor y have side effects themselves.

3.4. Constant Expressions

49 Simple assignment

Structure assignment has been added: its use was foreshadowed even in K&R, and
many existing implementations already support it.
The rules for type compatibility in assignment also apply to argument compati-
bility between actual argument expressions and their corresponding argument types
in a function prototype.
An implementation need not correctly perform an assignment between over-
lapping operands. Overlapping operands occur most naturally in a union, where
assigning one field to another is often desirable to effect a type conversion in place;
the assignment may well work properly in all simple cases, but it is not maximally
portable. Maximally portable code should use a temporary variable as an interme-
diate in such an assignment. Compound assignment

The importance of requiring that the left operand lvalue be evaluated only once is
not a question of efficiency, although that is one compelling reason for using the
compound assignment operators. Rather, it is to assure that any side effects of
evaluating the left operand are predictable.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->