HNHacker News
TopNewBestAskShowJobs

jadengeller

110 karma · joined February 16, 2016

submissionscomments
jadengeller··on Transmit 5
It looks like they just used three.js
jadengeller··on Introducing Ivy: a new smart contract language
Are there any useful contracts you might write that require Turing completeness?
jadengeller··on ‘Abusing’ the C switch statement – beauty is in the eye of the beholder
Macro lists are a rather elegant solution IMO. You cannot add cases to the enum without also adding cases to the switch.

  #define CMD_LIST CMD(1) CMD(2) CMD(3) CMD(4)
  #define STATUS_LIST STATUS(1) STATUS(2) STATUS(3)

  enum {
    #define CMD(x) CMD ## x = x - 1,
    CMD_LIST
    #undef CMD
    END_CMD
  };

  enum {
    #define STATUS(x) STATUS ## x = x + 9,
    STATUS_LIST
    #undef STATUS
    END_STATUS
  };

  void process_message(int x)
  {
    switch (x) {
      #define CMD(x) case CMD ## x:
      CMD_LIST
      #undef CMD
        process_command_msg(x);
        break;
      #define STATUS(x) case STATUS ## x:
      STATUS_LIST
      #undef STATUS
        process_status_msg(x);
        break;
      default:
        report_error(x);
        break;
    }
  }
It's unfortunate that it isn't possible to write a macro macro that expands to that gross def/undef boilerplate we use in the switch.
jadengeller··on Hillary and Bernie’s Quiet Email Battle
I think this difference makes sense though. Bernie has to convince his supporters that his campaign is picking up momentum, that he actually has a chance so they should go out and vote. On the other hand, Hilary needs to make her supporters worried enough about the competition that they won't just assume it'll be an automatic win, and so they'll vote.
← PreviousPage 2 of 2