多个嵌套范围

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>");
}

版画

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