I have used a 'goto'

Just starting out? Need help? Post your questions and find answers here.
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: I have used a 'goto'

Post by electrochrisso »

Thanks for the tips idle, this info will come in handy if I ever decide to use jump code.
The last time I used this stuff was on the C64. :)
PureBasic! Purely the best 8)
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Re: I have used a 'goto'

Post by utopiomania »

I have no problems with using goto once in a while , but it can be confusing to read the code later, and understand whats going on, if you like goto's too much... If so, comment a lot, for overall efficiency.
I think it's better to write sourcecode in a way that makes it easy to follow later on, in order to minimize time spendt on fixing bugs, or to change or improve things, write code that is easy to understand ? :)
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: I have used a 'goto'

Post by luis »

@BasicallyPure

If you want to read my opinion about GOTOs with PB in case you didn't read about it before:

http://www.purebasic.fr/english/viewtop ... 50#p330250

http://www.purebasic.fr/english/viewtop ... 32#p310632

http://www.purebasic.fr/english/viewtop ... 24#p374524

http://www.purebasic.fr/english/viewtop ... 97#p415897

http://www.purebasic.fr/english/viewtop ... 04#p310704

I don't post them because I get an orgasm from people reading them, but because I find important to fight the misconceptions surrounding it.
At least to give another opinion different from the mainstream view (even if on this forum there is a little more open-mindedness fortunately), then anyone can decide for himself.
:wink:


In your case above, I agree a "continue" is an acceptable choice. Even if it's a goto in disguise. But it's a goto "in chains", you know it has a limited scope, you know where it is headed, it is self-explanatory, etc.
Probably there is no need to use an "untamed" goto here but it's up to you, nothing wrong with it.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: I have used a 'goto'

Post by electrochrisso »

Verrrrrry interesting luis. :)
PureBasic! Purely the best 8)
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: I have used a 'goto'

Post by BorisTheOld »

@luis

Many good points.

It was around 1970, a couple of years after he published his GOTO-less programming paper, that Edsger Dijkstra gave a lecture at the University of Toronto. The topic was "Synchronizing Primatives", about the problems of synchronizing independent tasks. A few of us from the IBM lab in Toronto decided to crash the lecture to see if he had anything to say about GOTO statements, but sadly it wasn't to be.

At the time, there was a lot of discussion in our group about the merits of his ideas, the most generous being that he was totally insane. Most of us felt that his ideas for structured programming might solve some problems, but would create a whole set of new ones. We saw it as just another fad, like decision tables. Our main problem was with the ability of his structures to adequately handle asynchronous events, like hardware interrupts and error situations.

Dijkstra was very zealous and emotional about his ideas, much the way that OOP advocates are these days.
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense.
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.
Over the years, I've come to believe that programming has more to do with the skill of the programmer than it does with the tools that he uses. Elegant bug-free programs can be written with GOTO statements, and bugridden gibberish can be written using structured code or OOP. So although I use OOP and structured techniques with PB, I also willingly use GOTO statements if it makes my code clearer and more maintainable.

There's a good reason why, after 50 years of programming, I use PB as my language of choice. It gives me the flexibility I need, from ASM to OOP, and it's cross-platform.

We're lucky that PB allows us to use so many different ways to write our code, and I wouldn't discourage anyone from using GOTO statements.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: I have used a 'goto'

Post by skywalk »

Without proper 'Try - Catch', error handling in Basic sorta needs Goto's.
Anywhere else they are sloppy and can/should be avoided.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: I have used a 'goto'

Post by luis »

@boris

I remember the second part of the quote: "potential programmers mentally mutilated beyond hope of regeneration."
Pretty funny but I don't believe that. Principles of programming are always valid.

Initially they work together to form a mentality, guide you to approach problems, teach you how to abstract data and algorithms.
With those in place the language is just a tool. More or less comfortable, more or less tailored to specific domains, but what you learned works everywhere.
If you started with basic, c, asm or logo it's not important.

If one really feels "mentally mutilated" by starting with basic or cobol, he wasn't a "potential programmer" in the first place. He should just buy a console and play with it.

But I must end with a quote from "The Tao of Programming"

Each language has its purpose, however humble.
Each language expresses the Yin and Yang of software.
Each language has its place within the Tao.
But do not program in COBOL if you can avoid it.

:mrgreen:


BONUS:

Two Basic programmers according to ATARI

Image

Looks like one is using a pocket calculator and the one in the foreground is picking grapes absorbed in his thoughts.

All the above probably in space, judging from the little Jupiter colliding with Uranus (please no jokes about it).
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: I have used a 'goto'

Post by luis »

Today I found this at the supermarket, obviously I had to buy it.

Image

Pretty good :)
BTW: "prosecco" it's a sparkling white wine.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: I have used a 'goto'

Post by idle »

:lol: better watch out my wife will drink it before you open it.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: I have used a 'goto'

Post by luis »

Too late ! HIC !
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: I have used a 'goto'

Post by skywalk »

I want :)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Olli
Addict
Addict
Posts: 1200
Joined: Wed May 27, 2020 12:26 pm

Re: I have used a 'goto'

Post by Olli »

Is it a product from Goto islands ?
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: I have used a 'goto'

Post by BarryG »

PureBasic compiles to ASM and ASM uses its version of "Goto" everywhere ("JMP"). "Goto" is not bad if you use it properly.
User avatar
useful
Enthusiast
Enthusiast
Posts: 402
Joined: Fri Jul 19, 2013 7:36 am

Re: I have used a 'goto'

Post by useful »

Image
Dawn will come inevitably.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: I have used a 'goto'

Post by luis »

BTW: I must explain the label.
This wine come from an Italian region called Veneto, and they have (like many Italian regions) their own dialect.
In the local dialect the phrase "un goto de vin" means "a glass of wine".
So probably the name of the wine comes from there.
But to me when I saw it, it was a GOTO before anything else :)
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply