关键字注册 [英] Keyword register

查看:103
本文介绍了关键字注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是一些想法,想要看到任何解释。

在这个新闻组中建议我们应该避免使用

关键字注册。


但是它是一种语言功能,如果它对

实现没有帮助,可以免费忽略它。这种情况发生得非常广泛,我平台上所有的b $ b C ++编译器都忽略了这个关键字。


此外,寄存器的使用提供了我们做的额外保证。 />
没有得到这个变量的地址,这可能确实有助于实现进一步优化变量访问的

实现,这是其引入的原始目的毕竟。


为什么我们不应该使用注册?


考虑到它的实现意味着该关键字有助于它
确实是
,否则实施*应该*忽略它。


-

Ioannis Vranos

http://www23.brinkster.com/noicys

解决方案

* Ioannis Vranos:


使用寄存器还提供额外的保证,我们不会得到这个地址瓦里这可能确实有助于实现进一步优化变量访问,这毕竟是其引入的最初目的。




嗯,标准说''register''通常被忽略,如果对象的地址是




这表明你可以取地址一个''注册''变量。


据我所知,它不会说任何你不能说的。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和电子邮件中最烦人的事情是什么?


Alf P. Steinbach写道:

好吧,标准说''register''通常被忽略,如果对象的地址


这表明你可以拿地址o fa''注册''变量。

据我所知,它没有说任何你不能说的。




是的,标准说:


"寄存器说明符与自动说明符具有相同的语义

以及提示对象的实现宣布

将被大量使用。 [注意:提示可以忽略,在大多数

实现中,如果对象的地址是

,它将被忽略。 ?结尾注释]。

在任何情况下,我原来的问题为什么应该避免注册。


-

Ioannis Vranos

http://www23.brinkster.com/noicys


* Ioannis Vranos:


无论如何,我原来的问题仍然是为什么应该避免登记。




谁说应该避免?


但实际上,使用它并没有任何好处,而且/>
键入更多内容以及解析更多(针对人类读者)。


所以在实践中我们不会使用它,除非在做复制粘贴

的Duff'设备。 ;-)


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?


Just some thought on it, wanting to see any explanations.
It was advised in this newsgroups that we should avoid the use of
keyword register.

However it is a language feature, and if it offers no help to an
implementation, it is free to ignore it. And this happens widely, all my
C++ compilers in my platform ignore this keyword.

Also the use of register provides the additional guarantee that we do
not get the address of this variable which may indeed help an
implementation to optimise the variable access further, which was the
original purpose of its introduction after all.

So why we should not use register?

An implementation taking it into account means that the keyword helps it
indeed, otherwise the implementation *should* ignore it.

--
Ioannis Vranos

http://www23.brinkster.com/noicys

解决方案

* Ioannis Vranos:


Also the use of register provides the additional guarantee that we do
not get the address of this variable which may indeed help an
implementation to optimise the variable access further, which was the
original purpose of its introduction after all.



Well, the standard says ''register'' is typically ignored if the address
of the object is taken.

That indicates that you can take the address of a ''register'' variable.

As far as I can see it does not say anywhere that you can''t .

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Alf P. Steinbach wrote:

Well, the standard says ''register'' is typically ignored if the address
of the object is taken.

That indicates that you can take the address of a ''register'' variable.

As far as I can see it does not say anywhere that you can''t .



Yes, the standard says:

"A register specifier has the same semantics as an auto specifier
together with a hint to the implementation that the object so declared
will be heavily used. [Note: the hint can be ignored and in most
implementations it will be ignored if the address of the object is
taken. ?end note]".
In any case, my original question why register should be avoided remains.

--
Ioannis Vranos

http://www23.brinkster.com/noicys


* Ioannis Vranos:


In any case, my original question why register should be avoided remains.



Who says it should be avoided?

But as a practical matter, nothing is gained by using it, and
it''s more to type and more to parse (for the human reader).

So in practice we don''t use it, except when doing a copy-paste
of Duff''s device. ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


这篇关于关键字注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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