Why does scope(success) have to use exceptions?

Brad Roberts braddr at slice-2.puremagic.com
Wed Jan 16 16:34:21 PST 2013


On Thu, 17 Jan 2013, Era Scarecrow wrote:

> On Wednesday, 16 January 2013 at 23:19:20 UTC, Andrej Mitrovic wrote:
> > Sample code:
> > I was expecting callScope to be lowered down to the handwritten code in
> > callFunc in assembly, but instead it uses exceptions. Here's some simple ASM
> > for callFunc compiled with -c -release -O (no inline):
> > 
> 
>  Obviously your code won't throw, however that's now how scope works.
>
>  <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...

It's a QOI issue.  I know that parts of DMD are nothrow aware and will 
collapse away unnecessary layers, but obviously not all are.  The missing 
piece here is likely examining assignments to validate that they can't 
throw.  Probably not hard to make a meaningful improvement here.

Later,
Brad


More information about the Digitalmars-d mailing list