r/visualbasic • • May 05 '24

GoTo?

As I've been going through my studies I saw that GoTo still exists in VB. Could someone provide a real life use case for it? The one in the book could have been handled by a simple If Else statement.

1 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/RJPisscat May 06 '24

You are correct. One can be knee deep and the clearest, best way out is a GoTo.

The nasty attitudes about GoTo are anachronistic to the days of interpreters instead of compilers, and also some new programmers would jump into a For with a Goto.

I know you know this. I'm responding to you and not the other guy because I don't want to talk to them. It's like a religion to many people.

1

u/BCProgramming May 07 '24

Yes, Djikstra's entire essay was largely about the use of goto and gosub to try to mimic functions, because there was obviously no clear control flow; It also meant that you could jump anywhere so you'd have goto's or gosubs hopping right in the middle of a "routine" and stuff, which is certainly not something you can even try to do these days. The complaints were almost about the things people were writing in BASIC more than goto being available at all; after all it's a pretty direct equivalent to JMP instructions, and he never railed against Assembly language to my understanding.

All that said though, if you do need goto (or using a flag even) to deal with logic involving breaking out of a set of nested loops, it does suggest that perhaps the function is a bit complicated.

1

u/HomeworkInevitable99 Jul 19 '24

Yes. Gotos were used as part of the logic, and once you get several gotos, you are lost.