Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: cartesian_adjacent_iterate in map.h
Home

[Freeciv-Dev] Re: cartesian_adjacent_iterate in map.h

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxx
Cc: Freeciv-Dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: cartesian_adjacent_iterate in map.h
From: Vasco Alexandre Da Silva Costa <vasc@xxxxxxxxxxxxxx>
Date: Wed, 6 Feb 2002 22:00:47 +0000 (WET)

On Wed, 6 Feb 2002, Jason Short wrote:

> Raimar Falke wrote:
> > On Tue, Feb 05, 2002 at 10:20:53PM +0000, Vasco Alexandre Da Silva Costa 
> > wrote:

> In this case, there is more danger in using an if() statement than there 
> is in the continue.  If you just have
> 
>    if (normalize_map_pos(&IAC_X, &IAC_y)) {
> 
> in the macro, then a foolish/careless/clever user can insert an } else { 
> into the code that uses the macro, giving (probably) bad results.
> 
> This isn't really much of a concern, but it's there nonetheless...

Actually i think it would be nice to provide that functionality as an
option. I've seen a couple of places in the code that could use it.

> As to the macro, I'm all in favor of simplifying it.  I'd do it as
> 
> #define cartesian_adjacent_iterate(x, y, itr_x, itr_y)
> {
>    adjc_dir_iterate(x, y, itr_x, itr_y, _IAC_dir) {
>      if (!DIR_IS_CARDINAL(_IAC_dir))
>        continue;
> 
> but I think macro wrapping like this is frowned upon :-).

That may be more compact, but makes the loop iterate 8 times instead of 4
and adds a bunch of useless branches.

---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa



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