LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-22-2011, 01:04 AM   #16
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940

And if I say:

int n;
n = 0;


or

int n = 0;

so, in this case, 'n' is a variable not an expression, right?

3.10
Code:
  Lvalues and rvalues                                              [basic.lval]
  Expressions are categorized according to the taxonomy in Figure 1.
  1
                                                 expression
                                            glvalue      rvalue
                                       lvalue      xvalue      prvalue
                                  Figure 1 — Expression category taxonomy

Last edited by Aquarius_Girl; 12-22-2011 at 01:06 AM.
 
Old 12-22-2011, 02:38 AM   #17
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
n is an identifier of a variable, and as such it is an expression.
 
1 members found this post helpful.
Old 12-22-2011, 04:20 AM   #18
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,668
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
In compiler parlance, an "LValue" is anything that can meaningfully sit on the Left side of an assignment statement.

That is: it not only produces a value, but it can be assigned one. (As opposed to something, such as a constant or a function-call, that only produces a value.)

The term makes perfect sense if you are the sort of person who gets their jollies out of writing language compilers.
 
1 members found this post helpful.
Old 12-22-2011, 04:57 AM   #19
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by sundialsvcs View Post
In compiler parlance, an "LValue" is anything that can meaningfully sit on the Left side of an assignment statement.

That is: it not only produces a value, but it can be assigned one. (As opposed to something, such as a constant or a function-call, that only produces a value.)
that's roughly a repetition of what has been established in this thread so far.

[X] Doc CPU
 
Old 12-26-2011, 11:57 PM   #20
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Quote:
that's roughly a repetition of what has been established in this thread so far.
Not exactly, with the nonsense of "memory locations" and such. The part of the compiler that deals with lvalues doesn't have any notion of "memory locations". The only thing that determines whether something is an lvalue is whether or not the typechecker complains when you put on the left hand side of an assignment. Nothing more.

Code:
const int x = 0;
'x' is *not* an lvalue. You can't do "x = 5;" later in the code. That's it. Like SigTerm said earlier, this is an declaration with an initializer, not an assignment. Initialization follows a different set of rules.
 
Old 12-27-2011, 12:03 AM   #21
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
'x' is *not* an lvalue. You can't do "x = 5;" later in the code.
Not later ofcourse, but "first" time you can assign value to x, therefore
I called it a lvalue.
 
Old 12-27-2011, 10:28 AM   #22
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Quote:
Not later ofcourse, but "first" time you can assign value to x, therefore
I called it a lvalue.
It's not assignment. It's initialization. Don't confuse the two together, just because they both use the '=' symbol.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid lvalue in assignment cdw9997 Programming 9 05-05-2009 06:16 PM
lvalue operator / consumable objects ta0kira Programming 8 10-23-2008 09:27 PM
error: invalid lvalue in assignment nasim751 Programming 3 04-10-2008 01:59 PM
Error: invalid lvalue in assignment xxrsc Linux - Software 1 08-17-2006 01:43 PM
wait_event_interruptible - invalid lvalue in unary `&' 7.e.Q Programming 4 11-08-2004 02:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration