Click here to Skip to main content
12,449,440 members (60,590 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.8K views
2 bookmarked
Posted

The goto-less goto!

, 7 Feb 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Usually, gotos are used to clean up resources when exiting a function. I would recommend using the RAII[^] idiom. It also works works well in the presence of exceptions.For C# I would use IDisposable/using. If that's not possible, I'd use a finally clause to clean up.Everything else...
Usually, gotos are used to clean up resources when exiting a function. I would recommend using the
RAII[^] idiom. It also works works well in the presence of exceptions.

For C# I would use IDisposable/using. If that's not possible, I'd use a finally clause to clean up.

Everything else will eventually end up being messy.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jörgen Sigvardsson
Software Developer (Senior)
Sweden Sweden
I make software.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralSorry, I assumed you were going to use exceptions for your r... Pin
Wolfgang_Baron10-Feb-11 4:37
memberWolfgang_Baron10-Feb-11 4:37 
GeneralPerformance would greatly suffer? For using the RAII idiom? ... Pin
Jörgen Sigvardsson9-Feb-11 7:17
memberJörgen Sigvardsson9-Feb-11 7:17 
GeneralReason for my vote of 2 While your code would look nice, per... Pin
Wolfgang_Baron9-Feb-11 4:44
memberWolfgang_Baron9-Feb-11 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160811.3 | Last Updated 7 Feb 2011
Article Copyright 2011 by Jörgen Sigvardsson
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid