Kai Antweiler <[EMAIL PROTECTED]> 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 _______________________________________________ glob2-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/glob2-devel
