goto a no-go?

Dicebot public at dicebot.lv
Tue Oct 1 06:09:00 PDT 2013


On Tuesday, 1 October 2013 at 13:02:56 UTC, monarch_dodra wrote:
> On Tuesday, 1 October 2013 at 12:46:50 UTC, Dicebot wrote:
>> Can't you use scope guards for that too? Those work for any 
>> scope, not only function scope.
>
> I hadn't thought of that before, but I don't think so. scope 
> guards are designed to run a specific piece of code, no mater 
> the code path.
>
> What I mostly want to do is just break out of a "control block".
>
> Either that, or I'm being retarded...?

In that case you can always replace "control block + goto" with 
nested function + return + scope guard inside it (if some cleanup 
code needs to be run) unless I am missing something.

(I think your snippet misses actual labels so it was unclear:))


More information about the Digitalmars-d mailing list