Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6285) rand_map_pos using native coordinates
Home

[Freeciv-Dev] Re: (PR#6285) rand_map_pos using native coordinates

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6285) rand_map_pos using native coordinates
From: "rwetmore@xxxxxxxxxxxx" <rwetmore@xxxxxxxxxxxx>
Date: Thu, 2 Oct 2003 21:43:32 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Jason Short wrote:
> Jason Short wrote:
[...]
> 
>>+  native_to_map_pos(x, y, myrand(map.xsize), myrand(map.ysize));
> 
> Except, with a macro form of native_to_map_pos, that will not work.  At 
> all.  This new patch is better.
[...]

Using static global intermediate or passed in local working storage in
macros, allows one to define all arguments once and thus preserve the
function form compatibility.

As Jason says, One should never use indeterminate or volatile quantities
when using macros as a general rule, so the code fixes to use local
variable storage are correct in this case. But by the same token, if one
is switching from function to macro form and the function form has in the
past and probably will be the future the common code form, then there are
ways to make the macros compatible. Doing this anyway when possible can
never hurt.

In this case there is no problem no matter whether which of the two ways
one uses to provide working storage in this macro. Properly coding the
macro gives you this added compatibility and avoids such bugs for free.

Cheers,
RossW
=====




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