Author: José Carlos
Date: 09:44:26 03/05/04
Go up one level in this thread
On March 05, 2004 at 12:04:56, Russell Reagan wrote: >On March 05, 2004 at 03:39:02, José Carlos wrote: > >> Attacked = ((UINT64)File[n] << 16) & WhiteAll >>or instead of that: >> u64Attacked = ((UINT64)u8File[n] << 16) & u64WhiteAll >> >> When next year I come back to this line to make some change, I hope to find >>second verion rather than first. > >What if you move to a new 64-bit machine with lots of cache where accessing >individual bytes is significantly slower than accessing larger data (16-bit, >32-bit, or 64-bit)? Now you've got a lot of changes to make. > >With just about any modern IDE you can find out the type by placing the mouse >cursor over the variable. If you're using vi and gcc, well, you've got me there >:) It's of course a matter of taste in the end. When I watch the screen, like 40 lines of code, having the types in the prefixes make it clearer to me. >In your code I would still prefer to hide the bit twiddling to make it more >readable and abstract the HN away into the details. Maybe something like: > >Attacked = KnightAttacks(Square); Yes, of course. The example was just to show my point. The idea is when I read that line (some time in the future), be it in a small function or anywhere else, I find it usefull to immediately see I have a 8 bits thing being masked to a 64 bits thing. José C. >If you want to use HN within the KnightAttacks function, that would seem more >reasonable to me. Instead of worrying about what type everything is all over >your program, you just have to worry about what type the things are within small >little functions like that. They can be inlined of course, and with C++ they >will be typesafe so your compiler will yell at you if your types get messed up. > >But I guess this is still a personal preference. I like my code to be more >abstracted because I like to fiddle with it and change lots of things to see >what works better.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.