goto (outer) case

Steven Schveighoffer schveiguy at yahoo.com
Mon Feb 18 19:51:06 PST 2013


On Mon, 18 Feb 2013 22:45:29 -0500, Nick Sabalausky  
<SeeWebsiteToContactMe at semitwist.com> wrote:

> On Mon, 18 Feb 2013 22:30:48 -0500
> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote:
>>
>> Hm.. wouldn't plain goto work:
>>
>> > final switch(foo)
>> > {
>> > case Foo.a:
>> >     final switch(bar)
>> >     {
>> >     case Bar.bar:
>> >         goto HORRIBLE_HACK;
>> >         break;
>> >     }
>> >     break;
>> >
>> > case Foo.b:
>> > HORRIBLE_HACK:
>> >     break;
>> > }
>>
>> Not sure, didn't test.
>>
>
> Maybe, but as you say it's a "horrible hack", and since my motivation
> was for some code cleanup it's just kind of a wash.

My love for goto is not great.  I cringe using goto case even ;)

That being said, I have no problem using it when the situation calls for  
it.  If there's one thing I hate more than goto, it's copy-pasting code,  
especially in the same function.  If goto avoids that, I'm for it.   
Especially in an embedded project.

-Steve


More information about the Digitalmars-d-learn mailing list