[Kamailio-Devel] Use of goto

Henning Westerholt henning.westerholt at 1und1.de
Fri Jan 30 11:43:45 CET 2009


On Thursday 29 January 2009, Raúl Alexis Betancor Santana wrote:
> > probably making complex goto-based programming is a nightmare. But
> > sometimes, as some of you expressed, it makes the code cleaner. I tend
> > to use goto for two cases:
> > - error handling - where some cleanup is required, also helps if the
> > return code needs to be updated
>
> I prefer macro-expansion, you just update the #define and all will be ok.

Hi Raúl,

hmm, macros.. This is also a interesting topic. :-) I think that having too 
many macros also makes code complex and hard to read.

> > - processing done - for the reason of cleanups (lock releasing) and
> > having one return statement in order to spot quickly the return code in
> > case of ok.
>
> Maybe ... but better if you don't use that.
>
> > Anyhow, probably is (will be) the developer choice, as long as it has no
> > big impact, code beautifications are always subject of taste.
>
> Yes, it will be developer choice, but we are a comunity, so we must have a
> code style guide, and IMHO on that guide, use of goto must be disallowed.

There is a set of guidelines in the wiki (see development section), but these 
are no detailed guides, like you suggested. Its a bit a difficult topic, as 
this is in many areas just a matter of taste. E.g. some people prefer to have 
the if/ function braces at the same line, some in the next line, some people 
use 80 char line breaks, some not, some uses spaces before the braces or the 
comparison operators.. Its hard to find a consensus on this, as this 
discussions can get religious really fast. 

I think its important to have one, consistent style in e.g. a module, and its 
also important that the used style is sufficient readable. But more important 
for me is that the code is commented, and a structure that enables it to 
follow the logic, and this things.

Cheers,

Henning



More information about the Devel mailing list