why scope(success)?
Sean Kelly
sean at f4.ca
Wed May 10 15:52:36 PDT 2006
Derek Parnell wrote:
> On Thu, 11 May 2006 08:13:37 +1000, Sean Kelly <sean at f4.ca> wrote:
>
>> Chris Miller wrote:
>>> This gives me an idea, how about if there was scope(none) that is
>>> just like a regular block, but doesn't create a new scope. This would
>>> be for when you only need to group statements but have no interest in
>>> a new scope.
>>> void foo()
>>> {
>>> if(a) scope(none) { stuff(); scope(success) bar(); }
>>> baz();
>>> }
>>> bar() would execute after baz();
>>
>> It's a nasty hack, but:
>>
>> if(!a) goto blah;
>> scope(success) a.foo();
>> blah:
>> ...
>
> And I guess this is just as nasty ...
>
> scope(success) if (a) a.foo();
Preferable so long as the state of a is maintained until scope exit.
But all of this smacks as an attempt to use the scope feature in a
manner that wasn't intended.
Sean
More information about the Digitalmars-d
mailing list