HackerTrans
TopNewTrendsCommentsPastAskShowJobs

GhotiFish

no profile record

comments

GhotiFish
·há 13 anos·discuss
Yes. It is certainly more pithy.

ACTUALLY! It reminds me of a technique Bisqwit used when he made his emulator. He used strings to define the behavior of certain instructions, the strings were actually interpreted at compile time. Though I think this is a C++ specific trick.

http://www.youtube.com/watch?v=y71lli8MS8s

he brings in the instruction table at 1:30
GhotiFish
·há 13 anos·discuss
I'm certainly novice in C, but as I was reading, I wondered about this

  {"get",getCommand,2,"r",0,NULL,1,1,1,0,0},

  "The fourth field, set to "r", is specifying that the 
   command is read only and doesn’t modify any keys’ value 
   or state.  There are a whole bunch of one letter flags 
   that you can specify in this string that are explained 
   in detail in the nearby block comment.  The field 
   following this string  should always be set to zero, and 
   will be computed later.  It’s simply a bitmask 
   representation of the information implied by the string."
Why would you opt for this, when you could specify some constants and bitwise or them together? Isn't that a more common thing to do, than to calculate a bitwise flags at run time?

   COMMAND_READONLY | COMMAND_RANDOM | COMMAND_NOSIDEEFFECTS
ect ect ect.

I'm sure there's a good reason, but this style seems strange to me.

Maybe redis makes use of the string later? but I can't help but feel it should build the string based on the flags, rather than build the flags based on the string.
GhotiFish
·há 13 anos·discuss
because words dominance pushes its acceptance. You using it is pushing it on your neighbours. It is a small push, but many hands move mountains.