scope() statements and return

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 7 08:01:30 PDT 2014


On Tue, 07 Oct 2014 16:34:12 +0200
Timon Gehr via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> import core.exception;
> 
> void doStuff(){ }
> 
> void main() nothrow{
>      try{ doStuff(); }
>      catch(UnicodeException){ }
> }
> 
> Error: function D main 'main' is nothrow yet may throw
that's not the same as 'final try': anything that is not
UnicodeException or it's descendant will pass thru. for 'final try'
anything other will crash the program immediately. no, 'assert(0)' is
not the same.

> > i'm talking about my proposal, where non-final try/catch will not
> > make function nothrow, only 'final try' will do.
> I.e. additional annotation overhead without a point?
with a point. you even quoted it.

> > and anything that not
> > catched in this 'final' will abort the program immediately, without
> > any tries to do unwinding or executing scope() statements.
> 
> import core.stdc.stdlib;
> 
> void doStuff(){ throw new Exception(""); }
> 
> void main() nothrow{
>      scope(exit) assert(0);
>      try{ doStuff(); }
>      catch(Exception){ exit(2); }
> }
i see *alot* of overhead here. and 'exit()', which will not show what
exception was thrown. yes, we can print this info manually -- adding
even more overhead. with 'final try' reader immediately recognizes
writer's intentions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141007/25db97b7/attachment-0001.sig>


More information about the Digitalmars-d mailing list