glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [glob2-devel] Re: what was the cause of repair bug?


From: Joe Wells
Subject: Re: [glob2-devel] Re: what was the cause of repair bug?
Date: Tue, 17 Apr 2007 13:10:23 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Kai Antweiler <address@hidden> writes:

>> Level 1 building construction site: 0
>> Level 1 building completed: 1
>> Level 2 building construction site: 2
>> Level 2 building completed: 3
>> Level 3 building construction site: 4
>> Level 3 building completed: 5
>>
>> When a completeted level 1 building goes into construction, its
>> "technical level" goes from 1 to 0. If we take prev level when its at
>> 0, this is -1, which means invalid.
>
> The difference between construction site and building seems to be
> just the first bit.  Swapping that seems to be safer.
> "level ^=1;"
> ^ is binary xor, right?
>
>
> Better would be using different functions:
> newBuildingLevel:
>  assert (level <=4);
>  level &= 0xfe;
>  level+=2;
> convertToConstructionSite:
>  level |= 1;
> convertToBuilding:
>  level &=0xfe;
>
> We could use 0xe or 0x7 instead of 0x7e, but that is not the point.

I'd prefer to see the code move away from taking advantage of
properties of numbers and become more abstract.

-- 
Joe




reply via email to

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