[cfe-dev] injecting a member function
rjmccall at apple.com
Fri Feb 18 10:18:51 PST 2011
On Feb 18, 2011, at 1:49 AM, Eric Niebler wrote:
> On 2/18/2011 3:41 PM, John McCall wrote:
>> On Feb 18, 2011, at 12:25 AM, Eric Niebler wrote:
>>> On 2/18/2011 2:58 PM, John McCall wrote:
>>>> I think you want to make some sort of PropertyAccessOperator
>>>> expression. It would work basically like BinaryConditionalOperator
>>> Thanks, John. Do you mean "ConditionalOperator" (which is ternary)?
>> No, I mean BinaryConditionalOperator, which represents the GNU
>> omitted-middle-operand ?: extension, and which has similar issues with
>> a sub-expression that's used in multiple places. This is new in ToT.
> Ah. That's explains why I didn't see it. I'm on a fork that is a bit
> behind your trunk, and we don't have it yet. Forgive me for being a bit
> slow on the uptake.
No worries; I figured you were on a branch and just wanted to point
you at the new hotness. :)
>> It is represented in the AST: it's an expression node. Certain other
>> expression nodes can bind it to the result of an expression, which can
>> then be legitimately used in multiple places. The overall effect is like
>> a "let" expression in a functional language, where the OVE acts as a
>> reference to the bound variable. In functional syntax, my proposal was:
>> let tmp = obj in
>> tmp.setProp(tmp.getProp() + 1)
> In practical terms, that means that, when evaluating tmp, evaluate obj
> (once), and thereafter all other times tmp is evaluated, just use the
> result already computed. And this Just Works wrt lvalues and rvalues.
Right. When creating the OVE, you give it a type, value kind, and
value object kind matching the expression it gets bound to.
More information about the cfe-dev