lvalues

dmr at alice.UUCP dmr at alice.UUCP
Fri Jan 16 16:27:09 AEST 1987


The question of lvalues has arisen recently both in the context
of the silly C book review, and also in relation to the operand
of ++.  The term is old (it comes from BCPL or earlier) and
just denotes the things that can appear on the left (`l') of
an assignment.

The White Book and the current ANSI draft both waffle about whether
the term is formal or descriptive; they introduce it by, respectively,
"an expression referring to an object [which is a] manipulatable
region of storage;" and "an expression that designates an object."

It might cause less confusion if the definition were explicitly syntactic,
and only certain lvalues were permitted by the semantics to be
assigned to.  In this scheme, an lvalue (eliding precedence) is defined
as one of

	identifier
	( lvalue )
	lvalue . identifier
	* expression

Also, by applying equivalence rules,

	expression[expression]     =>    *(expression + expression)
	expression->identifier     =>    (*expression).identifier

Only some lvalues can appear on the left of `=' (e.g.: not array,
not const, not function).  Even more restrictions apply to operands
of `&': not register, not bit-field.

This suggestion doesn't change the language, but it makes it
clearer what an lvalue actually is.  Both the old and new
reference manuals make it hard for the reader to enumerate the possible
lvalues.

		Dennis Ritchie
		research!dmr



More information about the Comp.lang.c mailing list