why scope(success)?

Regan Heath regan at netwin.co.nz
Wed May 10 15:54:17 PDT 2006


On Wed, 10 May 2006 15:52:36 -0700, Sean Kelly <sean at f4.ca> wrote:
> 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.

Yeah. It's a pity though. What about:

int foobar( .. )
{
   if (a) {
     scope(success) scope(success) a.foo();
   }
}

I wonder.

Regan



More information about the Digitalmars-d mailing list