why scope(success)?

Walter Bright newshound at digitalmars.com
Fri May 12 11:30:33 PDT 2006


Daniel Keep wrote:
> When the "do cairo stuff" is just a simple function call, I don't really
> gain anything.  But it comes in handy when I've got to return values
> from cairo functions, or when I have to use any kind of complex logic.
> 
> Plus, I find reading "scope(success) checkStatus()" to be very clear;
> that, and it's immediately obvious just looking at the code if I've
> forgotten it (almost every function in the binding follows that pattern
> so exceptions to that are easily spotted).

Right. It eliminates the all-too-common bug of adding an extra return 
statement but forgetting to add the check/cleanup code that goes along 
with it.



More information about the Digitalmars-d mailing list