[cfe-commits] [PATCH] Expressions have lvalues and rvalues

wasti sebastian.redl at getdesigned.at
Fri Oct 10 01:52:46 PDT 2008


On Thu, 9 Oct 2008 22:21:47 -0700, Chris Lattner <clattner at apple.com>
wrote:
> On Oct 9, 2008, at 8:07 AM, Sebastian Redl wrote:
> 
>> Zhongxing Xu wrote:
>>> We have two kinds of RVal: LVal and NonLVal. LVal represents location
>>> value,
>>> NonLVal represents non-location value.
>> All other considerations aside, this terminology is a spawn of the
>> deepest hell and must be eradicated. Rvalue/lvalue considerations are
>> complicated enough without messing them up this way.
> 
> Sebastian, please be civil here - we attempt to maintain a positive  
> and helpful community.  What are you getting at? What do you suggest?

I'm sorry. But I've always learned that rvalues and lvalues are strictly
opposed. The statement above thus is illogical - rvals cannot be lvals or
non-lvals. Non-lvals *are* rvals. Values can be lvalues or rvalues.
Anything else is opposed to the terminology the C++ standard (at least)
uses and can only bring chaotic confusion. In a few months, nobody will be
able to understand the code in question anymore.

In fact, something I've noticed in the code of Clang is that rvalues and
lvalues are not seen as strictly distinct, probably because this
distinction is not that important in C. In C++, with references and (in
C++0x) rvalue vs lvalue references, with complicated rules about which
temporaries can be elided that also partially depend on rvalue vs lvalue
issues, this distinction feels very important to me. In writing code (and
thinking about code to write) for validation of the C++ cast operators, I
have felt the lack of a clear distinction as something that made my code
harder to understand.

I will look at the code to give some concrete suggestions as soon as I can.
However, I just started a new job, and my life is somewhat hectic at the
moment.

Sebastian



More information about the cfe-commits mailing list