why scope(success)?

James Dunne james.jdunne at gmail.com
Wed May 10 13:42:15 PDT 2006


Regan Heath wrote:
> On Tue, 9 May 2006 22:36:03 -0400, Ben Hinkle <ben.hinkle at gmail.com> wrote:
>> I believe writing "scope(success) foo;" followed by the end of the  
>> current scope is equivalent to just writing "foo;". Maybe I'm  
>> misunderstanding the example.
> 
> You're right. For some reason I got it in my head that scope(success)  
> happened when the function itself returned, as opposed to the current  
> scope closing.
> 
> So, what about in this case:
> 
> int foobar( ..etc ..)
> {
>   if (a) scope(success) a.foo();
>   //A: immediately after if
> }
> //B: at function return
> 
> when does a.foo() get executed? at A or B? I get the impression it's A.
> 
> Regan

if statements do not create a scope without { }, therefore it should be 
at B.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e 
h>--->++ r+++ y+++
------END GEEK CODE BLOCK------

James Dunne



More information about the Digitalmars-d mailing list