DMD 0.148 - scope guard

Georg Wrede georg.wrede at nospam.org
Tue Feb 28 16:47:17 PST 2006


Chris Miller wrote:
> On Mon, 27 Feb 2006 17:16:38 -0500, Dawid Ciężarkiewicz  
> <dawid.ciezarkiewicz at gmail.com> wrote:
> 
>> Chris Miller wrote:
>>
>>> This format looks good to me:
>>>
>>> scope(exit)  foo();
>>> scope(success)  bar();
>>> scope(failure)  baz();

This gets my vote too.

And then it would look natural, if you ever need more than one function run:

scope(failure) foo();
scope(success) { bar(); haveAParty(); writeHome(); }
scope(exit) yawn();

>> Yeap. It's nice. Maybe s/success/pass/ s/failure/fail/ would even  
>> improve it
>> a little.
> 
> Good one.

That's kind of neat, too. Having all three alternatives with same number 
of characters, makes it tidy:

scope(exit)  foo();
scope(pass)  bar();
scope(fail)  baz();

Except of course, that "pass" might look like "skip" to somebody new to D.



More information about the Digitalmars-d mailing list