D Language Scope guards Multiple, nested scopes


Example

import std.stdio;

void main() {
    writeln("<html>");
    scope(exit) writeln("</html>");
    {
        writeln("\t<head>");
        scope(exit) writeln("\t</head>");
        "\t\t<title>%s</title>".writefln("Hello");
    } // the scope(exit) on the previous line is executed here

    writeln("\t<body>");
    scope(exit) writeln("\t</body>");

    writeln("\t\t<h1>Hello World!</h1>");
}

prints

<html>
    <head>
        <title>Hello</title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>