What's an LValue [was A quick question]
Stephen Carlson
scc at rlgvax.Reston.ICL.COM
Fri Mar 15 05:09:25 AEST 1991
In article <1991Mar13.050555.26149 at tandem.com> jimbo at tandem.com (Jim Lyon) writes:
>In article <31306 at shamash.cdc.com> bls at u02.svl.cdc.com (Brian Scearce) writes:
>>The rules are pretty easy (especially if you have your copy of
>>Harbison and Steele on your desk :-)
>>
>>0. variable names (excepting function, array and enum constant
>> names) are lvalues.
>>1. e[k] is an lvalue, regardless of whether e and k are lvalues.
>>2. (e) is an lvalue iff e is.
>>3. e.name is an lvalue iff e is.
>>4. e->name is an lvalue regardless of whether e is an lvalue.
>>5. *e is an lvalue regardless of whether e is an lvalue.
>
>Rules (1) and (5) need to be further qualified.
[ Points well taken deleted, please refer to original article. ]
Rules (1) and (4) are technically redundant.
Since e[k] <=> *((e)+(k)), rule (1) is a special case of Rule (5).
Since e->name <=> (*e).name, rule (4) is a special case of Rules (3), (2),
and (5):
*e must be an lvalue By rule 5
=> (*e) must be an lvalue By rule 2
=> (*e).name must be an lvalue By rule 3
=> e->name must be an lvalue By definition of ->
Hence, rule (4).
However, it is better to present a practical set of rules than a logically
minimal set of rules.
--
Stephen Carlson | ICL OFFICEPOWER Center | In theory, theory and
scc at rlgvax.reston.icl.com | 11490 Commerce Park Drive | practice are the same.
..!uunet!rlgvax!scc | Reston, VA 22091 |
More information about the Comp.lang.c
mailing list