Specification of executing order of multiple scope(s)

An Pham home at home.com
Wed May 31 15:52:08 UTC 2023


Should the scope failure to be executed before exit regardless of 
the code order?

import std.exception, std.stdio;

     void test()
     {
         writeln("test");

         scope (failure)
         {
         	writeln("failure");
         }

         scope (exit)
         {
             writeln("exit");
         }

         throw new Exception("exception");
     }

     void main()
     {
         try
         {
             test();
         }
         catch (Exception e) writeln(e.msg);
     }

Output
test
exit
failure
exception


More information about the Digitalmars-d mailing list