Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7075) break and continue in iterators
Home

[Freeciv-Dev] Re: (PR#7075) break and continue in iterators

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: a-l@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7075) break and continue in iterators
From: "rwetmore@xxxxxxxxxxxx" <rwetmore@xxxxxxxxxxxx>
Date: Sat, 3 Jan 2004 08:56:33 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7075 >


Iterators are most often implemented as simple loops, and in these
cases break works as expected. This should be the standard behaviour.

Some iterators are coded as double loops, and in these cases break
will usually fail or fail to do the expected. There is no reason not to
reimplement all iterators as single loops for consistency as once done
they are canned constructs. But so far this has not been done.

The comment for each iterator should spell out such conditions to make
it clear what the current internal format permits/requires. This can be
simplified to defining the standard expected behaviour and commenting
exceptions for those that are still using double loops.


The (ab)use of GOTO is a longstanding religious issue in programming
circles and shouldn't need to be rehashed here. Practically, one should
avoid using it if there are trivial alternatives, but not go to extreme
lengths of code obfuscation just to avoid it when it is the correct
solution.


Cheers,
RossW
=====

Arnstein Lindgard wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7075 >
> 
> "break" inside iterate_outward{} doesn't work. Maybe not surprising
> since the macro uses a for() loop inside a while() loop. Sometimes
> "break" has the effect of a "continue", and that took a deliberate
> effort to detect. This can easily become hard to find bugs for the
> unwary.
> 
> If "goto" is perfectly valid C, less ambigous and equally well
> defined as "break", then what exactly are the reasons for
> discouraging it's use?
> 
> Arnstein




[Prev in Thread] Current Thread [Next in Thread]