1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Goto?

Discussion in 'HTML, Graphics & Programming' started by Lagz, 23 Jan 2006.

  1. Lagz

    Wise Guy

    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.
     
  2. roboffer

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 9,599

    Location: Sunderland

    Which language?
     
  3. Berserker

    Man of Honour

    Joined: 4 Nov 2002

    Posts: 15,443

    Location: West Berkshire

    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 :)
     
  4. Lagz

    Wise Guy

    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.
     
  5. Berserker

    Man of Honour

    Joined: 4 Nov 2002

    Posts: 15,443

    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 of course be barking up the wrong forest. :)
     
  6. Lagz

    Wise Guy

    Joined: 25 Jul 2003

    Posts: 1,980

    Aye thats probably right then (its only a minor point anyway).

    Thanks
     
  7. roboffer

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 9,599

    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!
     
  8. SiriusB

    Capodecina

    Joined: 16 Dec 2005

    Posts: 14,448

    Location: Manchester

    Doesn't matter which is "better". GOTO's are inherently bad lol.

    SiriusB
     
  9. NathanE

    Capodecina

    Joined: 21 Oct 2002

    Posts: 18,022

    Location: London & Singapore

    Using GOTO suggests you aren't using the language's other flow constructs properly. Program flow should be handled by loops and conditionals.
     
  10. Mattus

    Capodecina

    Joined: 30 Sep 2003

    Posts: 10,907

    Location: London

    Out of interest, does anyone know if there's an equivalent function to GoTo in Javascript?
     
  11. happytechie

    Soldato

    Joined: 18 Oct 2002

    Posts: 5,601

    Location: Surrey

    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.
     
  12. Visage

    PermaBanned

    Joined: 13 Jan 2005

    Posts: 10,708


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