March 07, 2008 Re: Missed scope guard statements | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Fraser | Robert Fraser wrote:
>
> Compile-time values could evaluate to true, and compile-time code generation could very easily create code that would seem silly to write directly. So it's a valid problem.
You are right, this is a problem.
Interestingly, mixing in the ThenStatement works fine:
----
if (true)
mixin ("scope(exit) Stdout(\"hello \").newline;");
// prints hello as expected.
----
I guess, this is because a string mixin creates a new scope, which is a bug (or a feature? The specification is not specific on that):
----
mixin ("scope(exit) Stdout(\"Exiting scope.\").newline;");
Stdout("After mixin").newline;
----
outputs:
Exiting mixin scope.
After mixin
while I would expect the reverse.
|
Copyright © 1999-2021 by the D Language Foundation