I wonder if it's possible to do something like this:

import std.stdio;

void main(string[] args)
{
   if (args[1]=="a")
   {
       write("A");
       scope (exit) write("B");
   }

   write("C");
}

I expected the output to be ACB not ABC. I understand, that the scope ends at the end of the if, but I wonder, if it's possible to have a "conditional scope" or something like this.

I found a workaround using "finally", but anyway I'm curious.

Reply via email to