Bjarne关于异常规范的评论 [英] Bjarne's comments about exception specification
问题描述
大家好,
您如何理解Bjarne关于异常
规格的评论?特别是,不需要检查
compilation-unit和违规行为不会在运行时被捕获?
第14.6.1节检查异常规格
------ --------------
重要的是,不需要在编译单元边界之间检查异常规范
。当然,
的实现可以检查。但是,对于许多大型且长寿命的b $ b系统而言,重要的是实现不会 - 或者,如果它b
,那么它只是小心地给出了硬错误违规行为将在运行时被捕获。
--------------------
提前感谢,
George
Hello everyone,
How do you understand the Bjarne''s comments about exception
specification? Especially, "not required to be checked across
compilation-unit" and "violations will not be caught at run time"?
section 14.6.1 Checking Exception Specifications
--------------------
Importantly, exception-specifications are not required to be checked
exactly across compilation-unit boundaries. Naturally, an
implementation could check. However, for many large and long-lived
systems, it is important that the implementation does not -- or, if it
does, than it carefully gives hard errors only where violations will
not be caught at run time.
--------------------
thanks in advance,
George
推荐答案
2008-01-20 11:26,Alf P .Steinbach写道:
On 2008-01-20 11:26, Alf P. Steinbach wrote:
* George2:
* George2:
>大家好,
你如何理解Bjarne关于异常
规范的评论?特别是,不需要通过编译单元检查。和违规行为不会在运行时被捕获?
第14.6.1节检查异常规格
-------------- ------
重要的是,不需要在编译单元边界之间检查异常规范。当然,
实施可以检查。然而,对于许多大型和长期存在的系统而言,重要的是实施不会 - 或者,如果它确实如此,而不是仅仅在违规行为不会发生的情况下才会出现严重错误在运行时被抓住。
--------------------
>Hello everyone,
How do you understand the Bjarne''s comments about exception
specification? Especially, "not required to be checked across
compilation-unit" and "violations will not be caught at run time"?
section 14.6.1 Checking Exception Specifications
--------------------
Importantly, exception-specifications are not required to be checked
exactly across compilation-unit boundaries. Naturally, an
implementation could check. However, for many large and long-lived
systems, it is important that the implementation does not -- or, if it
does, than it carefully gives hard errors only where violations will
not be caught at run time.
--------------------
我想知道你在哪里发现它和它的年龄。
如果它指的是C ++,那么根据现行标准(1998)它是不正确的,
并且也是关于1991 ARM的错误。
I wonder where you found that and how old it is.
If it refers to C++ then it''s incorrect per the current standard (1998),
and was also incorrect with respect to the 1991 ARM.
这是第3版。 TC ++ PL,但它脱离了上下文。我认为
他指的是编译器是否会在编译时给出任何警告/错误(虽然我在标准中找不到任何提及)。
第14.6.1节首先讨论在编译时检查异常 -
规范以及引用后的段落
表示关键是你不必通过所有的b
代码并更新你的异常规范只是因为你做了一些
更改,允许更多例外被抛出。
-
Erik Wikstr ?? m
It is in the 3rd ed. of TC++PL, but it is taken out of context. I think
he is referring to whether the compiler will give any warnings/errors at
compile-time (though I can not find any mentioning of this in the standard).
Section 14.6.1 starts by talking about checking of exception-
specifications at compile-time and the paragraph after the quoted one
says that the point is that you should not have to go through all your
code and update your exception-specifications just because you make some
change that allows more exceptions to be thrown.
--
Erik Wikstr??m
有没有人使用异常现实世界中的规格?我认为它们很难在一段时间后继续遵守它们,并且在定义它们时总是很准确。
$ / b $ b
Does anyone use exception specifications in real world? I think they are
difficult to keep complying with them after some time, and are difficult
to be always accurate when defining them.
在2008-01-20 13:26,Ioannis Vranos写道:
On 2008-01-20 13:26, Ioannis Vranos wrote:
有没有人在现实世界中使用异常规范?我认为它们很难在一段时间后继续遵守它们,并且难以确定定义它们时总是准确的。
。
Does anyone use exception specifications in real world? I think they are
difficult to keep complying with them after some time, and are difficult
to be always accurate when defining them.
空指定(throw())非常有用,表示
函数没有抛出(可以很好地知道何时处理异常
安全)。但除此之外,我没有看到任何广泛使用它。
-
Erik Wikstr ?? m
The empty specification (throw()) is quite useful to indicate that a
function does not throw (can be good to know when dealing with exception
safety). But other than that I do not see any widespread use of it.
--
Erik Wikstr??m
这篇关于Bjarne关于异常规范的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!