scope(failure): get exception

Jonathan M Davis jmdavisProg at gmx.com
Mon Oct 29 03:58:43 PDT 2012


On Monday, October 29, 2012 10:30:35 Jacob Carlborg wrote:
> On 2012-10-28 13:20, Jonathan M Davis wrote:
> > So, you save one set of braces? I don't see how that really buys you much.
> 
> Yes, and the "try" keyword. It would basically be the same as allowing
> to get the exception in scope(failure) but the catch-statement already
> supports this.

Except that the place that scope statements go in the code is completely 
different from where catch statements go. catch statements go at the end 
whereas scope statements go in the middle or even the beginning so that what 
you're doing in there can be close to code that corresponds to it (e.g. you 
can have the code for releasing a resource right after the code for aquiring 
it rather than having it in a complete separate part of the code. What you 
typically do with scope  statements and try-catch statements is often 
fundamentally different.

I can understand wanting to be able to have access to the exception that's 
flying by in a scope statement, but I really don't see how saving a try and 
couple of braces adds much. Certainly, the two are completely different in 
terms of what they buy you.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list