On 11-04-14 12:52 PM, Brandon McCaig wrote:
I often use gotos in C for error handling within a function. If
you're allocating resources and something later on fails then you
usually want (or need) to clean up those resources before
returning. I've seen a lot of people duplicate the same cleanup
code over and over again. I hate doing that. Goto makes it much
cleaner. Just because you can make spaghetti with goto doesn't
mean goto always has to make spaghetti. You do need to be careful
though and assess any given situation carefully.

You can replace the goto with the correct use of setjmp(3) and longjmp(3). These are the exception handlers in C.


--
Just my 0.00000002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to