Goto?

I thought goto was banned purely on principle. :p

New forum rule anyone? ;)

Sorry for the unhelpful post, it's just instinct from my student days :-)
 
Heh. Any language (its a general term I believe, specifically fortran has them. The description I found didn't help though). More generally whats the difference between an indirect and direct function call.

I'm not actually using them. I'm doing a compilers course and it describes how to treat them. I'm guessing that indirect means the target of the goto/function call is decided at runtime rather than compile time (badness!), but its only a guess.
 
I'm guessing you have that about right. In C at anyrate, I'd consider a direct function call as being calling the function by name (compile time), whereas indirect as calling the function using a function pointer (runtime). Other languages (COBOL for one) allow you to call programs (similar to functions in other languages) by name at run-time, so you can build up a string in a variable and call that, so the story is a little more complicated than name vs pointer.

For indirect function calls, there are tricks you can use to determine the target when doing code analysis, but they're rarely suitable for a compiler, so the latter is almost impossible to optimise. For direct calls, you can do all sorts of optimisation.

I could have course be barking up the wrong forest. :)
 
I didnt have a clue anyway, I was guessing it must have been some old language and was just sticking my oar in attempt to help someone else answer it.

Id say direct ones are better, indirect ones are just gay!
 
Using GOTO suggests you aren't using the language's other flow constructs properly. Program flow should be handled by loops and conditionals.
 
yes use a function call or a switch statement :D

gotos can still be used in any language but their use leads to a spiders web of code that is rediculously hard to debug.
 
SiriusB said:
Doesn't matter which is "better". GOTO's are inherently bad lol.

SiriusB


Not true. They have greater *potential* for problems than any other construct, but that doesnt mean that they are unconditionally bad.
 
Back
Top Bottom