Goto?

Associate
Joined
25 Jul 2003
Posts
1,980
Whats the difference between an indirect and direct goto? arg. Cant seem to find out on the internet.
 
Associate
OP
Joined
25 Jul 2003
Posts
1,980
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.
 
Man of Honour
Joined
4 Nov 2002
Posts
15,508
Location
West Berkshire
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. :)
 
Soldato
Joined
18 Oct 2002
Posts
9,598
Location
Sunderland
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!
 
Permabanned
Joined
13 Jan 2005
Posts
10,708
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