Jump to content

this always bugged me :P


Recommended Posts

The problem with Goto is the ease with which a novice, or even an experienced, programmer can make very convoluted programs which get exponentially more difficult as the program gets bigger. Look up spaghetti code on Wikipedia for some ideas about this. Debugging or maintaining a program full of Gotos is a lot more difficult than one that uses a structured programming language, like AutoIt 3. Because part of our focus was to make a language that was easy to learn, goto's were chucked so that people could more easily debug their scripts. Also, using structured programming allows tools like Tidy (part of the AutoIt SCite editor) to organize the structure and easily find when structures get out of hand.

I hope this helps.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

one thing always bugged me about any programing language: why do EVERYONE HATE the goto thing?

it works pretty nicely o.O

i never use it to have my dignity though.

i don't hate it, but everyone else seems to hate the goto thing and everyone who use it.

Get a job maintaining RPG code on AS/400. You will probably learn to hate it to..:)
Link to comment
Share on other sites

From what I've seen goto is mostly used to jump to cleanup code at the end of a function. However, my experience seeing goto in use is from Microsoft examples or Microsoft generated code. I don't use goto, of course, so I simulate the same idea using a for(;:) loop which I conditionally break out of on error and unconditionally break out of after one complete loop. The advantage to this is C++ destructors are correctly invoked and it still only requires the cleanup code to be in one place and it's easy to jump to the cleanup using a break statement.

Edit: I use the same technique and have shown an example a couple times on the forum, as well.

Edited by Valik
Link to comment
Share on other sites

I read somewhere that goto is mostly used to break more than one loop when not being used in a beginner fashion. A real programmer could make sentinels to continue breaking loops if more than one break was needed.

We have implemented multiple level ContinueLoop and ExitLoop to accommodate this. No need for goto here. :)

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...