Graham Fawcett <[email protected]> wrote:

On Tue, 11 May 2010 22:18:29 +0200, Don wrote:

void foo(bool x)
{
    if (x)
       scope(exit) writeln("exiting");
    writeln("body");
}

Doesn't this do what you want, without changing the language?

void foo(bool x) {
    scope(exit) {       
      if (x) writeln("exiting");
    }
    // ...
}

Absolutely. but it is currently possible to write the code Don
wrote, have it compile, and feel that this is completely
pointless. Which it is.

That is, if scope(whatever) is the only thing inside a scope,
something is wrong. D already warns us of other stupid things
we do, and this is a prime candidate.

--
Simen

Reply via email to