[Kamailio-Devel] Use of goto

Daniel Corbe daniel.junkmail at gmail.com
Tue Jan 27 22:57:55 CET 2009


There are cases where goto makes code more readable not less readable.  Take
nested loops, for example where you need to break out of the outer most loop
from inside the inner most loop.  Currently there are no semantics to do
that cleanly other than using a goto or adding a bunch of arbitrary and
unnecessary logic to determine when you are finished.
-Daniel

On Tue, Jan 27, 2009 at 1:45 PM, Alex Balashov <abalashov at evaristesys.com>wrote:

> Raúl Alexis Betancor Santana wrote:
> > El Martes, 27 de Enero de 2009 21:13, Daniel Corbe escribió:
> >> You should read http://kerneltrap.org/node/553/2131
> >> There's plenty of cases where goto is justified and certainly branching
> out
> >> into error conditions is one of them.  At least on the intel
> architecture
> >> goto typically translates 1:1 to the jmp instruction and is monumentally
> >> more efficient than constructing complex and hard to understand loops.
> >
> > Goto statements should be avoided, it's not a matter of how much time it
> takes
> > to "goto", it's a matter readability of the code
> >
>
> Except where performance really matters.
>
> In the case of error handling of atypical situations, probably not very
> important.
>
> In the case of something that is inline to the core's processing of
> every request, on the other hand...
>
> --
> Alex Balashov
> Evariste Systems
> Web    : http://www.evaristesys.com/
> Tel    : (+1) (678) 954-0670
> Direct : (+1) (678) 954-0671
> Mobile : (+1) (678) 237-1775
>
> _______________________________________________
> Kamailio (OpenSER) - Devel mailing list
> Devel at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/devel
> http://lists.openser-project.org/cgi-bin/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/devel/attachments/20090127/d67feffb/attachment.htm 


More information about the Devel mailing list