Funny you should mention that. Here is a deeply nested do loop in
VB.NET from Wei-Meng Lee's Sudoku book, that Reflector showed as a
series of If-Then-Else statements each having a goto statement
pointing to the top of the series (not only that, but the IL didn't
consolidate the NOP targets, so for instance, if there are 10 nested
do loops, each Exit Do pointed to its own NOP.
Do '---Look for Triplets in Columns
Do '---Look for Triplets in Rows
Do '---Look for Triplets in Minigrids
Do '---Look for Twins in Columns
Do '---Look for Twins in Rows
Do '---Look for Twins in Minigrids
Do '---Look for Lone Ranger in Columns
Do '---Look for Lone Ranger in Rows
Do '---Look for Lone Ranger in
' Minigrids
Do '---Perform Col/Row and
' Minigrid Elimination
changes = _
CheckColumnsAndRows()
If (HintMode
AndAlso changes) _
OrElse
IsPuzzleSolved() Then
ExitLoop = True
Exit Do
End If
Loop Until Not changes
If ExitLoop Then Exit Do
'---Look for Lone Ranger in
' Minigrids
changes = _
LookForLoneRangersinMinigrids()
If (HintMode AndAlso changes) _
OrElse IsPuzzleSolved() Then
ExitLoop = True
Exit Do
End If
Loop Until Not changes
If ExitLoop Then Exit Do
'---Look for Lone Ranger in Rows
changes = LookForLoneRangersinRows()
If (HintMode AndAlso
changes) OrElse _
IsPuzzleSolved() Then
ExitLoop = True
Exit Do
End If
Loop Until Not changes
etc. on up the chain....
In Reflector, this broke down to..
Label_0005:
Label_0006:
Label_0007:
Label_0008:
Label_0009:
Label_000A:
Label_000B:
Label_000C:
Label_000D:
Do
flag1 = Me.CheckColumnsAndRows
If Me.IsPuzzleSolved Then
flag2 = True
Exit Do
End If
Loop While flag1
If Not flag2 Then
flag1 = Me.LookForLoneRangersinMinigrids
If Me.IsPuzzleSolved Then
flag2 = True
ElseIf flag1 Then
goto Label_000D
End If
End If
If Not flag2 Then
flag1 = Me.LookForLoneRangersinRows
If Me.IsPuzzleSolved Then
flag2 = True
ElseIf flag1 Then
goto Label_000C
End If
End If
etc.....
In any case, compilers, whether targeting intermediate or machine
code, often make use of unconditional branches (i.e. IL or ML "goto")
to express higher level logic. "We do the dirty work, so you don't
have to..."
On 6/21/06, Mike Andrews <[EMAIL PROTECTED]> wrote:
Hmmm....
I'm still not entirely convinced, but they do make good cases for GOTO.
I suppose I need to look at the IL from a VB program with Exit Do nested
inside a Select Case statement inside a Do loop.
Perhaps it just inserts goto statements itself.
On 6/20/06, Roy Green <[EMAIL PROTECTED]> wrote:
>
> Michael Covington had a great article about restoring the reputation
> of the goto statement, but unfortunately I can't find it, as his other
> hobby is astrophotography, and there is apparently a species of
> computerized telescope called GoTo.. and a Google search is clogged
> with such results.
>
> Ah, here it is:
> http://www.covingtoninnovations.com/michael/blog/0509/index.html#050918
>
> and he points to Steve McConnell's page at
> http://www.stevemcconnell.com/ccgoto.htm
>
>
>
>
>
> On 6/20/06, Mike Andrews <[EMAIL PROTECTED]> wrote:
> > No, I've not considered it. I'd rather set a flag variable to make it
> work
> > rather than do anything with goto.
> > I just believe it's bad programming practice to use goto's.
> >
> > Thanks,
> > Mike
> >
> >
> > On 6/20/06, Toulakis, Dimitrios (RESC) <
> [EMAIL PROTECTED]>
> > wrote:
> > >
> > > Hi Mike,
> > >
> > > Have you considered using the goto statement?
> > >
> > > Cheers,Dimitrios
> > >
> > > -----Original Message-----
> > > From: Discussion of advanced .NET topics.
> > > [mailto:[EMAIL PROTECTED] On Behalf Of Mike Andrews
> > > Sent: Tuesday, June 20, 2006 3:49 PM
> > > To: [email protected]
> > > Subject: [ADVANCED-DOTNET] Exit Do...
> > >
> > > Guys...
> > >
> > > I know that break; is essentially the same as a VB Exit Do.
> > >
> > > However...
> > >
> > > If I'm inside a switch statement, is it possible to exit the Do loop?
> > >
> > > Thanks,
> > > Mike
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor(r) http://www.develop.com
> > >
> > > View archives and manage your subscription(s) at
> > > http://discuss.develop.com
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor(r) http://www.develop.com
> > >
> > > View archives and manage your subscription(s) at
> > > http://discuss.develop.com
> > >
> >
> > ===================================
> > This list is hosted by DevelopMentor(r) http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com
> >
>
> ===================================
> This list is hosted by DevelopMentor(r) http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com