October 11, 2013 Re: goto a no-go? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 03-Oct-2013 07:37, Andrei Alexandrescu пишет: > On 10/2/13 8:14 PM, deadalnix wrote: >> On Thursday, 3 October 2013 at 02:21:19 UTC, Andrei Alexandrescu wrote: >>> On 10/2/13 10:06 AM, Dicebot wrote: [snip] >> Or more generally cope statement at the end of a scope. > > I'm cautious about that; that's why I specified "unbraced". Consider: > > if (lily) > { > scope(exit) writeln("Lily was here."); > // fun(); > } > > This code is a plausible edit of work that was meaningful and in which > the programmer has temporarily commented out the call to fun. If the > compiler would obnoxiously protest that the edited code can't compile, > that may be more aggravation than win for the user. > > In contrast, this is no simple edit of any sensible code: > > if (lily) > scope(exit) writeln("Lily was here."); > > Here, the compiler is much more within its rights to demand a code > change, either to > > scope(exit) if (lily) writeln("Lily was here."); > > or > > if (lily) writeln("Lily was here."); > Truth be told I'd be _very_ cautious of the tiny special cases like this, they make generating D code (including at CTFE) a PITA. -- Dmitry Olshansky |
Copyright © 1999-2021 by the D Language Foundation