Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Map coordinate cleanups.
Home

[Freeciv-Dev] Re: Map coordinate cleanups.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Map coordinate cleanups.
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Fri, 17 Aug 2001 02:24:27 +0200

On Thu, 16 Aug 2001, jshort@xxxxxxxxxxxxx wrote:
> Gaute B Strokkenes wrote:
> 
> I think any benefit players may get from extra speed is more than
> negated by the extra work developers have to do to use a macro for
> these functions.

What extra work?  There is zero extra work, in all but the most
unlikely of circumstances.  ("Unlikely" in this case means that in the
entirety of the Freeciv source there is not a single spot where this
makes a difference; I know because I checked before making the patch.)

> Thus I agree that there is no _good_ reason to make it a macro.
> 
> In summary, I don't think these functions should be made macros. 
> Efficiency must be balanced with code cleanliness.

I see zero code cleanliness issues with having these functions as
macros, other than a general "macros must be bad" attitude.

>> I haven't redefined anything; there is no evidence anywhere in the
>> current sources that this has been given any thought at all.
> 
> As I see it, you've redefined "normal", never mind that the original
> definition may have been by accident.
> 
>> In any case my point is that
>> 
>>   Stepping of the edge of the world.
>> 
>> and
>> 
>>   Accidentally forgetting to wrap an x coordinate.
>> 
>> are DIFFERENT kinds of error, and accordingly you want to be able
>> to detect either kind or both according to your needs.
> 
> You're right on this point; I understand what you're saying entirely
> I just disagree with your naming.  I would name things like this:
> 
> real tile: a coordinate position that is on the world
> proper tile: a coordinate that is canonically wrapped
> normal tile: one that is both real and proper

Ah, I think I can see where you're coming from now.

In mathematics, it is often the case that when dealing with an object
or group of objects that there is a more-or-less arbitrary choice,
based on convenience or simplicity, between objects or
representations.  For instance, suppose that I want to represent the
heading of the antenna on a space satelite.  The natural way to do
that is to use a 3D vector.  However, there are lots of vectors that
could be used.  The usual thing to do is to divide the vector by its
length, a process known as normalisation.  After normalisation, there
is only one, unique vector for each given heading.

It seemed obvious to me that the phrase "normalize_map_pos" had been
picked because of the meaning of normal or normalized as "in the
preferred form" rather than the commonplace meaning as "plain,
ordinary" which is how you seem to be interpreting it.

I then picked "proper" because that is the word which is most often
used to exclude objects which fit the definition, but are not `nice'.
For instance given a set A, A is a subset of A--but it is not a proper
subset.

I suppose it's my fault for not remembering that not everyone has the
same background as I do.  I'll make sure that I document this
properly.

> Currently normalize_map_pos takes care of both, checking both
> validity and wrapping - which is why I believe my naming system is
> most consistent with what's currently in freeciv.

normalize_map_pos() has the return value that it has because that is
obviously the most useful thing for it to return.  If you look at the
comment, you will see that it states "returns TRUE if it is real".  I
don't think it is reasonable to extrapolate the meaning of the word
"normal" based on this.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
Hey!!  Let's watch the' ELEVATOR go UP and DOWN at th' HILTON HOTEL!!


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