why scope(success)?

Stewart Gordon smjg_1998 at yahoo.com
Thu May 11 08:36:01 PDT 2006


Chris Miller wrote:
<snip>
> void foo()
> {
>    if(a) scope(none) { stuff(); scope(success) bar(); }
>    baz();
> }
> 
> bar() would execute after baz();

I'm not sure about this.  Of course, it would need to be illegal to 
declare anything within a scope(none) block.

Implementing scopeless conditionals would add a runtime dependence to 
the ScopeStatement mechanism.  The program would have to either note the 
value of the conditional at the time, or use some kind of function stack 
to keep track of which ScopeStatements will be executed.

Moreover, what if it's a loop rather than an if?  Should the cleanup 
code be executed once for each iteration of the loop, all at once when 
exiting the scope containing the loop?

Stewart.

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

My e-mail is valid but not my primary mailbox.  Please keep replies on 
the 'group where everyone may benefit.



More information about the Digitalmars-d mailing list