问题描述
我知道RAII和BS对先前请求的回应,但我真的很想看到'b $ b'喜欢在C ++异常处理中看到''finally''。是的,我们可以在没有''终于'的情况下生活
但是这意味着更多的打字(更多课程)
简单的场景(比如在函数前调用LeaveCriticalSection())
返回)。它还可以将其他语言移植到C ++中更简单。
我想看到的另一件事是''可重入''关键字可以是
应用于函数和方法。当非重入函数被标记为可重入时,编译器应该具有投诉所需的所有信息
。
I know about RAII and BS''s response to previous requests, but I''d really
love to see ''finally'' available in C++ exception handling. Yes, we can
live without ''finally'' but it means a bit more typing (more classes) for
simple scenarios (like calling LeaveCriticalSection() before a function
returns). It would also make porting other languages to C++ a bit more
simple.
Another thing I''d like to see is a ''reentrant'' keyword that can be
applied to functions and methods. The compiler should have all the info
necessary to complain when a non-reentrant function is labeled as reentrant.
推荐答案
那么编译器将如何识别不可重入的功能?
-
Joe Seigh
当你拿柠檬时,你做柠檬水。
当你拿到硬件时,就会制作软件。
So how would the compiler identify a non-reentrant function?
--
Joe Seigh
When you get lemons, you make lemonade.
When you get hardware, you make software.
那么编译器如何识别非可重入函数?
So how would the compiler identify a non-reentrant function?
它不使用静态或全局变量。但是一个新关键字是
''不成比例''。
It uses no static or global variables. But a new keyword is
''disproportionate''.
您可能对RAII不太了解(足够)。否则你不会想要一个''终于''。
You probably don''t know (enough) about RAII. Otherwise you wouldn''t
want a ''finally''.
这篇关于我想在C ++ 2009中看到两件事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!