From: Carsten Haitzler (The Rasterman) <raster@ra...> - 2012-09-26 23:36:41
On Wed, 26 Sep 2012 21:29:39 +0200 Tom Hacohen <tom@...> said:
> On 26/09/12 21:19, Eduardo Lima (Etrunko) wrote:
> > On Wed, Sep 26, 2012 at 4:01 PM, Enlightenment SVN
> > <no-reply@...> wrote:
> >> Log:
> >> Ecore_Evas (wayland): Remove goto. (don't need them, don't want them)
> > Why? There is goto all over the code.
> Yeah. Furthermore, in my point of view, the code you removed is by an
> order of magnitude better than the new code. A common cleanup location
> for functions is a good thing...
that is indeed a good point. the "goto's are evil so never use them" brigade
has ultimately had a negative effect. - devilhorns - now on you. :) goto's have
their place. don't use liberally - buty use them WHEN they simplify flow.
examples. exception handling (if (!something) goto err;) and in err: u hav e
common shared cleanup code that cleans up any stuff u have begin to build/alloc
etc. - it saves repeating this again and again. it also saves nesting like a
cleanup type 3
cleanup type 2
cleanup type 1
if (!a) goto err;
if (!b) goto err;
if (!c) goto err;
which one of these is easier to read and maintain? hell which is easier to
WRITE? the point of "goto is evil" is when you use gotos INSTEAD of
while/for/if etc. flow control and then the code becomes HARD to follow with
lots of gotos jumping about. you no longer easily see the flow of the code.
when a goto is used to break out of several nestings of for/while etc. sections
without having it bit by bit break out of each one separately, or i'ts used to
group some common cleanup code to simplify something, then they are good.
simply - do they improve code readability and maintainability,. if they do -
then use them. :)
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler) raster@...