terminology: "l-value" & "r-value"

Steven Schveighoffer schveiguy at yahoo.com
Tue Jan 4 07:17:07 PST 2011


On Tue, 04 Jan 2011 08:55:07 -0500, spir <denis.spir at gmail.com> wrote:

> Hello,
>
> I'm bluffed by the 2 terms "l-value" & "r-value" used in C-line language  
> common terminologies. I think I guess what they mean, but I don't  
> understand the need for such absconse idioms. Why not:
> 	l-value <-> variable
> 	r-value <-> value (or expression)
> ?
>
> I guess (*p) is considered an l-value. Indeed, it's a special way of  
> denoting a variable, matching the special case of a pointer. If correct,  
> this requires slightly extending the notion of variable (and/or of  
> identifier).
> On the r-value side, I cannot find anything that makes it a distinct  
> concept from the one of value, or of expression.
>
> Explanations welcome, thank you,
> Denis

lvalue stands for left value, rvalue stands for right value.  They  
describe which side of the equation they are on:

lvalue = rvalue;

Why these terms instead of something more natural?  Well, I have no idea  
:)  If I were to guess, it would be that no natural term could exactly  
describe the meaning, and also that using natural terms are subjective.   
There's no mistaking what lvalue and rvalue mean becausey they are defined  
by the language itself.

I'm sure Walter probably knows the origin, l and r values are really  
compiler terms, and he's been writing compilers for a long time.

-Steve


More information about the Digitalmars-d-learn mailing list