|
I grew up on assembly code in the late 70's so I have no issues using goto's in my coding (C/C++ these days) when approriate. The idea that goto's are inherently bad is just bogus. There is a relatively small class of functions that are shorter and easier to understand when coded with a goto as opposed to the convoluted looping required to do the same thing. And being an old fart, shorter and easier to understand is a good thing! Especially when I have to add new features to code I wrote years ago.
|
|
|
|
|
As others have said, it's largely what Try Catch does. It has been pointed out though that using break and return in a method is really the same thing in a way. I've used on goto in my code, but based on that last sentence I plan to use them regularly though in the future, just always within a method. Instead of a catch -> return -> handle error, use a catch -> goto error handling at end of method -> end of method returns.
|
|
|
|
|
Does anyone remember when the use of gotos was first discussed? Does anyone remember the reason Dijkstra gave for their elimination?
To me, I'm sorry, this thread seems somewhat juvenile
Gus Gustafson
|
|
|
|
|
It's not bad, it's dangerous. But there's use cases where it's better than, let's say, 12 nested ifs. Did that myself, some COM-code which calls COM-methods in order I've placed gotos between method calls to directly jump to cleanup/deinitialization/error handling instead of a pile of if NoError=SomeMethod {if NoError=NextMethod). Way cleaner, but requires knowing what I'm doing. One wrong goto and I'm screwed.
|
|
|
|
|
there's nothing inherently wrong with goto, it's just another tool that works just like OP jump codes on a processor, jumping the running process to another memory location.
It's quite handy too when the code structure gets nested too deep or you can't use recursion; it has it's place, and can keep the code more readable when done right.
Unfortunately before structured programming came around that's all you had to move around, this was quite common in early version of BASICA or GW, where using subroutines wasn't as common. all this turned in to spaghetti code, earning procedural languages like Basic a bad rep (that stuck). the developers that grew up on these early languages unfortunately carried this forward using goto's everywhere, making it a nightmare to debug when something went wrong.
My personal rules for goto's:
*keep the function as short as possible so you can see the GOTO and the LABEL on the screen at the same time.
*never use more than one redirection, ie multiple goto's to one label is fine if absolutely necessary, but never ever use multiple goto's and multiple labels, that just too much jumping around, and gets hard to follow.
*does the code look cleaner and easier to follow with a goto or using check values with more if's?
*can the process be restructured to avoid the deep nesting that caused a goto to be used in the first place.
*keep the code as simple as possible.
That being said, I've used goto maybe 5-10 times in my 20+ years developing, and I don't regret it.
|
|
|
|
|
Maybe too easy, but let's see ...
Assistant Inspector George Roberts originally enrolled in the London force as a commissaire (7)
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
Maigret ?
Met around initials of assistant inspector George Roberts
We can’t stop here, this is bat country - Hunter S Thompson RIP
modified 20-Jun-19 5:35am.
|
|
|
|
|
Yep, we have a winner.
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
As you said a bit too easy but a very nice clue ( multiple use of police related stuff )
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
|
Someone f***** up.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
It's an undocumented feature (or at least it was... until now...)!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- Never argue with a fool. Onlookers may not be able to tell the difference. Mark Twain
|
|
|
|
|
so does it print the round or round the print?
|
|
|
|
|
First round is on printer!
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Way to go, printer!
|
|
|
|
|
I love how this bug is confirmed on pretty much all browsers on pretty much all OS'es.
We get it guys, it's a bug
|
|
|
|
|
Soon to be a feature!
|
|
|
|
|
Super Lloyd wrote: Soon to be a feature!
A feature is just a bug with seniority.
|
|
|
|
|
Reading the comments on that one is awesome:
Quote: I tried this on IE5.5 in a MacOS 9 VM and an Apple Laserwriter II spontaneously materialized on the floor
cheers
Chris Maunder
|
|
|
|
|
118. Policeman's root? (4)
|
|
|
|
|
BEAT / BEET (Probably the first, could be the latter)
Policeman's route : BEAT
Policeman's root : BEET
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
He's good at these isn't he ?
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Ya
|
|
|
|
|
Do science jokes give you a hadron?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Do science jokes give you a hadron?
Too bad you didn{t switch the r and d around. and add a space before the o.
Then you would qualify as a number 1 nerd.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
modified 20-Jun-19 12:16pm.
|
|
|
|