Interesting (and clean!) use of goto.

Life As I Know It

Well all the programmers know that “Goto is bad”. Now-a-days people are avoiding it and many languages do not support it. The following sketch by xkcd also summarizes the harmfulness of Goto.

And poor Goto has been taken to task by none other than Dijkstra. I used to be a strong opponent of Goto as well.

But while going through the book Advanced Mac OS X Programming by Mark Dalrymple and Aaron Hillegass, the frequent use of Goto made me change my opinion. The authors have used Goto elegantly to avoid conditional nesting.

Those who code in languages like C or C++ with no or half support for exceptions need to depend on error codes to determine the success or failure of a method. Suppose we write a method which is dependent of 5-6 more methods to do the task. After invoking each method we need to check the…

View original post 308 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s