English Amiga Board


Go Back   English Amiga Board > Main > Retrogaming General Discussion

 
 
Thread Tools
Old Yesterday, 10:33   #141
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,863
Quote:
Originally Posted by Thorham View Post
C does have goto
Yes, I know. I was having a dig at people who insist BASIC is bad because it has GOTO, while forgetting that purportedly superior 'structured' languages also have it.

Goto
Quote:
Goto (goto, GOTO, GO TO, GoTo, or other case combinations, depending on the programming language) is a statement found in many computer programming languages...

The structured program theorem proved that the goto statement is not necessary to write programs that can be expressed as flow charts; some combination of the three programming constructs of sequence, selection/choice, and repetition/iteration are sufficient for any computation that can be performed by a Turing machine, with the caveat that code duplication and additional variables may need to be introduced....

Probably the most famous criticism of GOTO is a 1968 letter by Edsger Dijkstra called "Go-to statement considered harmful". In that letter, Dijkstra argued that unrestricted GOTO statements should be abolished from higher-level languages because they complicated the task of analyzing and verifying the correctness of programs (particularly those involving loops). The letter itself sparked a debate, including a ""GOTO Considered Harmful" Considered Harmful" letter...

Other programmers, including Linux kernel designer and coder Linus Torvalds or software engineer and book author Steve McConnell, also object to Dijkstra's point of view, stating that GOTOs can be a useful language feature, improving program speed, size and code clarity, but only when used in a sensible way by a comparably sensible programmer. According to computer science professor John Regehr, in 2013, there were about 100,000 instances of goto in the Linux kernel code.
Bruce Abbott is offline  
Old Yesterday, 10:39   #142
gimbal
cheeky scoundrel
 
gimbal's Avatar
 
Join Date: Nov 2004
Location: Spijkenisse/Netherlands
Age: 43
Posts: 7,124
I tend to be on the side of the opinion that does not assume people will walk into clearly visible bear traps. They have functioning brains and eyes.

Yes goto is a sketchy language feature. So is pointer arithmetics. So is an old style switch statement with automatic fallthrough. So are singletons. So are global variables. Etc. Etc. They are still power tools in the right circumstances.
gimbal is offline  
Old Yesterday, 13:04   #143
AestheticDebris
Registered User
 
Join Date: May 2023
Location: Norwich
Posts: 531
Goto in C isn't the same beast as goto in BASIC though. For one, you have to have labels for the destination, so it's easier to reason about (sure you can still write spaghetti, but you can regardless of whether you use goto).

The problem in BASIC was that goto could take you to absolutely any line, sometimes even a line number based on an arbitrary calculation. Plus it was often the only form of flow control available apart from subroutines. Now it was certainly possible, with discipline, to maintain a good structure but the whole deal with BASIC coding was it was accessible to people who didn't have that discipline. And thus a lot of BASIC programs rapidly descended into impossible to follow flows that were all over the place.
AestheticDebris is offline  
Old Yesterday, 13:15   #144
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,975
Exactly. Old school goto was like jumps and branches in assembly language. Takes effort not to make a mess in and is certainly not great for beginners because of it.
Thorham is offline  
Old Yesterday, 16:02   #145
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,419
To be fair, it's only the early variants of BASIC that use line numbers and can do that. Anything remotely modern (as in, anything from the past 30 years or so) will require labels to execute a Goto as well.
Daedalus is offline  
Old Yesterday, 17:56   #146
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,963
Not only C, goto is still valid C++ even. It checks the branch isn't skipping over the initialisation of anything that might then be used inappropriately when you compile it, which is about as safe as you can reasonably get. One place where goto crops up a fair amount is in machine generated code.
Karlos is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to find variant of this song Flow Res. Kenny Amiga scene 1 11 August 2023 21:58
A1200 case, desktop variant? Malakie Amiga scene 6 11 December 2021 18:12
Preferred Falcon variant eXeler0 Retrogaming General Discussion 19 20 November 2020 00:40
How to specify the game variant used in Arcade Mode? ketschak support.FS-UAE 2 07 March 2014 14:31

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:17.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07998 seconds with 12 queries