473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

operators requiring lvalue/rvalue operands and resulting in rvalue/lvalue

These were the questions asked to me by my friend

1. Operator which may require an lvalue operand, yet yield an rvalue.
2. Operator which may require an rvalue operand, yet yield an lvalue.

My answer to these questions are & and * respectively.

Is/Are there any other operator(s) satisfying these criteria?

Oct 27 '06 #1
9 3128
Kavya wrote:
These were the questions asked to me by my friend

1. Operator which may require an lvalue operand, yet yield an rvalue.
2. Operator which may require an rvalue operand, yet yield an lvalue.

My answer to these questions are & and * respectively.
The * operator doesn't require an rvalue.
Is/Are there any other operator(s) satisfying these criteria?
The [] operator.

Regards,
Bart.

Oct 27 '06 #2
In article <11**********************@f16g2000cwb.googlegroups .com>,
Kavya <Le******@gmail.comwrote:
>1. Operator which may require an lvalue operand, yet yield an rvalue.
Surely *all* operators yield rvalues? Or do you mean "rvalue which is
not an lvalue"? (The standard does not define "rvalue", but a footnote
says it is the same as the "value of an expression".)

The argument to & may be a function name, which is not an lvalue.

The ++ and -- operators require an lvalue and do not yield one.
>2. Operator which may require an rvalue operand, yet yield an lvalue.
Similarly, surely all operators require rvalue operands? Presumably
you mean "rvalue that is not necessarily an lvalue".

The operators [] and -also produce lvalues from things that are not
necessarily lvalues.

-- Richard
Oct 27 '06 #3
Richard Tobin:
Surely *all* operators yield rvalues?

I believe the general consensus is that an expression is labelled either as
an R-value or an L-value, not that an L-value also qualifies as an R-value.

By this understanding, the following expression works upon an R-value, yet
yields an L-value:

*p

--
Ahmed Kalembo
Oct 27 '06 #4
Ahmed Kalembo <nu**@null.nullwrites:
Richard Tobin:
>Surely *all* operators yield rvalues?

I believe the general consensus is that an expression is labelled either as
an R-value or an L-value, not that an L-value also qualifies as an R-value.
The term "lvalue" is defined by the standard (though the definition is
very poorly worded); the term "rvalue" is informally defined by the
standard in a footnote. Any "consensus" about what they mean is
irrelevant, at least in this newsgroup.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 27 '06 #5
Keith Thompson:
The term "lvalue" is defined by the standard (though the definition is
very poorly worded); the term "rvalue" is informally defined by the
standard in a footnote. Any "consensus" about what they mean is
irrelevant, at least in this newsgroup.

Consider the two concepts:

(1) declaration
(2) definition

A "declaration" is also a "definition", but not vice-versa. What I was trying
to express is that the L-value and R-value situation is dissimilar to this.
While it is correct to say that a "definition" is also "declaration", I don't
believe that it's right to say that an "L-value" is an "R-value", because I
believe that by calling something an "R-value", you're explicitly saying that
it is _not_ an L-value.

It is true that an L-value can do everything (and more) that an R-value can
do, but I wouldn't go so far as to say that it's OK to call an L-value an R-
value.

In short, if you were to tell me that something is an R-value, I'd interpret
it as:
"This is an R-value, not an L-value."

--
Ahmed Kalembo
Oct 27 '06 #6
Ahmed Kalembo:
A "declaration" is also a "definition", but not vice-versa.

I worded that wrongly; I should have written:

A "definition" is also a "declaration", but not vice-versa.

--

Frederick Gotham
Oct 27 '06 #7
Frederick Gotham:
Ahmed Kalembo:
>A "declaration" is also a "definition", but not vice-versa.


I worded that wrongly; I should have written:

A "definition" is also a "declaration", but not vice-versa.

Sorry about the name mix-up. I'm not socket-puppeting, the computer I'm using
has multiple users at the moment.

--

Frederick Gotham
Oct 27 '06 #8
Kavya wrote:
These were the questions asked to me by my friend

1. Operator which may require an lvalue operand, yet yield an rvalue.
2. Operator which may require an rvalue operand, yet yield an lvalue.
...
What exactly is the meaning of "require" in "require an rvalue operand"? Take
the unary '-' for example. It operates on rvalues, but one can always use a
valid lvalue as an operand (which will be implicitly converted to an rvalue).
Does that mean that unary '-' actually _requires_ an rvalue or not?

--
Best regards,
Andrey Tarasevich
Oct 27 '06 #9
In article <Xn**************************@194.125.133.14Ahme d Kalembo <nu**@null.nullwrites:
....
What I was trying
to express is that the L-value and R-value situation is dissimilar to this.
While it is correct to say that a "definition" is also "declaration", I
don't believe that it's right to say that an "L-value" is an "R-value",
because I believe that by calling something an "R-value", you're
explicitly saying that it is _not_ an L-value.
That may be your opinion, but that is not necessarily the opinion of
others. There is nothing in the standard (or elsewhere) that would
make something calling an "R-value" that same something not an "L-value".
That is what you get when you are using terms that are undefined. My
reading has always been that an "L-value" (in principle) can be used
at the left side of an assignment and an "R-value" at the right side.
(I ignore the non-midifiable "L-values".)
It is true that an L-value can do everything (and more) that an R-value can
do, but I wouldn't go so far as to say that it's OK to call an L-value an R-
value.
You just use your personal definition of "R-value", apparently.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Oct 28 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steven T. Hatton | last post by:
This is from the draft of the previous version of the Standard: http://www.kuzbass.ru:8086/docs/isocpp/expr.html 2- A literal is a primary expression. Its type depends on its form...
24
by: Romeo Colacitti | last post by:
Hi, Does anyone here have a strong understanding for the meanings of the terms "lvalue" and "rvalue" as it pertains to C, objects, and different contexts? If so please share. I've been...
10
by: Axel Dahmen | last post by:
Hi, I want to start a technical discussion on the fact that C# doesn't define any mathematical operators on other integral types than int. Simple things like the following just aren't possible...
28
by: dspfun | last post by:
I'm trying to get a good understanding of how unary operators work and have some questions about the following test snippets. int *p; ~!&*++p--; It doesn't compile, why? The problem seems to be...
14
by: nobrow | last post by:
Yes I know what lvalue means, but what I want to ask you guys about is what are all valid lvalues ... a *a a *(a + 1) .... What else?
6
by: Lighter | last post by:
How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a...
6
by: Yarco | last post by:
I've alway thought lvalue means Left Value and rvalue means Right Value before i've read someone's article. It is said "lvalue = location value" and "rvalue = read value". Which one is right, then?
9
by: usao | last post by:
Does anyone have an example of how to create a class which describes and array, such that I can use the subscript operator on both the left and right side of an assignment statement? This is as...
2
by: Chad | last post by:
The following question actually stems from an old Chris Torek post. And I quote from the following old CLC url ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.