On 17/01/2013 00:06, Era Scarecrow wrote:
<snip>
  Consider a block containing a scope(exit) statement:
<snip>
  However if compiler knows and can verify the code is unable to fail
(thus exceptions are not needed) perhaps an enhancement request that
could remove the unneeded try/catches...

The OP was talking about scope(success), not scope(exit). scope(success), by definition, won't be executed if the code fails. If it does it by changing it to a try/finally, it has to generate extra code to test whether the code succeeded or not. It's far simpler to just write out the scope(success) code at the end of the scope in question. As such, the compiler is _pessimising_ the code.

OK, so it's a bit more complicated if the scope can be exited via a return, break, continue or (dare I mention?) goto statement, but even then it ought to be quite easy to make the compiler generate more efficient code.

This should be fixed, as it is discouraging use of scope(success).

Stewart.

Reply via email to