comp.lang.c
[Top] [All Lists]

Re: ?: as an lvalue

Subject: Re: ?: as an lvalue
From: Andrey Tarasevich
Date: Mon, 31 Mar 2008 12:06:43 -0700
Newsgroups: comp.lang.c


Willem wrote:
) > ...
)> But (c?x:y)=v;
)> I dont really know what to say. ) ) Is there any reason why you believe that the property of "being an ) lvalue" should be necessarily lost in the process of selection from two ) lvalues of the same type?
)
) I mean I'm OK personally with the way it works in C. I just like to know ) what is it exactly in '(c?x:y)=v' that triggers a "I don't really know ) what to say" reaction from some people.

Well then why not also make it possible for functions (that return
 pointers) to be lvalues ?

  returnspointertostruct(foo)->bar = baz;

Or is that already legal ?

This is perfectly legal. It's just that has nothing to do with the function. Function still returns a non-lvalue. The left-hand side expression though

  (non-lvalue pointer)->bar

is an lvalue. This why you can assign to it.

What's illegal is this

  returnsstruct(foo).bar = baz;

i.e. function returns a 'struct' in this case .

--
Best regards,
Andrey Tarasevich

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy