什么是左值? [英] Whats an lvalue?

查看:89
本文介绍了什么是左值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的我知道左值是什么意思,但我想问你们的是

什么都是有效的左值...


a

* a

a [1]

*(a + 1)

....

还有什么?


什么语法/正则表达式描述所有有效的左值?

解决方案

< blockquote> no****@gmail.com 写道:


是的我知道左值是什么意思,但我想问你们的是

什么都是有效的左值...


a

* a

a [1]

*(a + 1)

...

还有什么?



所有这些都可能是也可能不是左值,取决于'/'
对于'a'是什么。


什么语法/正则表达式描述所有有效的左值?



编写生成所有左值表达式的
a语法会很简单,虽然很乏味,但它会是

也接受一些不是左值的表达式。作为左值的

属性是语义的,而不是语法的。


-

Eric Sosman
es ***** @ acm-dot-org.inva lid


3月6日上午7:54,Eric Sosman< esos ... @ acm-dot-org.invalidwrote:


>

[...]


a

* a

a [1]

*(a + 1)

...

还有什么?



所有这些都可能是也可能不是左值,取决于'/'
是什么'。

[...]



为什么你说* a,a [1]和*(a + 1)可能不是左值?对于知道的一样多的

,一元*运算符和[]运算符总是需要一个表示有效对象地址的

表达式,并且它们总是

返回左值。


rg


Rg写于03/06/07 13 :11,:$​​ b $ b


3月6日上午7:54,Eric Sosman< esos ... @ acm-dot-org.invalidwrote:


>> [...]


>>> a
* a
a [1]
*(a + 1)
...
还有什么?


所有这些都可能是也可能不是左值,取决于'a'是什么。

[...]




为什么你说* a,a [1]和*(a + 1)可能不是左值?对于知道的一样多的

,一元*运算符和[]运算符总是需要一个表示有效对象地址的

表达式,并且它们总是

返回左值。



int a [5] [10];

a [1] = ...?


-
Er*********@sun.com


Yes I know what lvalue means, but what I want to ask you guys about is
what are all valid lvalues ...

a
*a
a[1]
*(a + 1)
....
What else?

What grammar/regexp describes all valid lvalues?

解决方案

no****@gmail.com wrote:

Yes I know what lvalue means, but what I want to ask you guys about is
what are all valid lvalues ...

a
*a
a[1]
*(a + 1)
...
What else?

All of these might or might not be lvalues, depending
on what `a'' is.

What grammar/regexp describes all valid lvalues?

It would be straightforward, although tedious, to write
a grammar that generates all lvalue expressions, but it would
also accept some expressions that are not lvalues. The
property of being an lvalue is semantic, not grammatical.

--
Eric Sosman
es*****@acm-dot-org.invalid


On Mar 6, 7:54 am, Eric Sosman <esos...@acm-dot-org.invalidwrote:

>
[...]

a
*a
a[1]
*(a + 1)
...
What else?


All of these might or might not be lvalues, depending
on what `a'' is.

[...]

Why do you say *a, a[1] and *(a + 1) may not be lvalues? For as much
as know, the unary * operator and the [] operator always require an
expression that represents a valid object''s address, and they always
return lvalues.

rg


Rg wrote On 03/06/07 13:11,:

On Mar 6, 7:54 am, Eric Sosman <esos...@acm-dot-org.invalidwrote:

>>[...]

>>>a
*a
a[1]
*(a + 1)
...
What else?


All of these might or might not be lvalues, depending
on what `a'' is.

[...]



Why do you say *a, a[1] and *(a + 1) may not be lvalues? For as much
as know, the unary * operator and the [] operator always require an
expression that represents a valid object''s address, and they always
return lvalues.

int a[5][10];
a[1] = ...?

--
Er*********@sun.com


这篇关于什么是左值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆