2006-09-29

ANSI C, lvalue

Value (computer science) 


In C: L-value and r-value

Some languages use the idea of l-value and r-value. L-values are values that have addresses, meaning they are variables or dereferenced references to a certain place. R-value is either l-value or non-l-value — a term only used to distinguish from l-value. In C, the term l-value originally meant something that could be assigned (coming from left-value, indicating it was on the left side of the = operator), but since 'const' was added to the language, this now is termed a 'modifiable l-value'.

An l-value is an expression that designates (refers to) an object. A non-modifiable l-value is addressable, but not assignable. A modifiable l-value allows the designated object to be changed as well as examined. An r-value is any expression that is not an l-value, it refers to a data value that is stored at some address in memory.

沒有留言: