Comment

Comment by mikewarot

Browsing the source code, I came across something completely unexpected. I didn't know you could put code in structs like this sample from kamby/kamby.c

  struct KaNode *ka_add(struct KaNode *node, struct KaNode **env) {
    if (node->type == KA_STR && node->next->type == KA_STR) {
      struct KaNode *output = ka_str(node->str);
      strcat(output->str, node->next->str);
      return output;
    }
    return ka_num(node->num + node->next->num);
  }
Is this legal? If so, I'm going to use the heck out of it for my version of STOIC.

[Edit] Ok.. thanks for the help.. I'm used to seeing function types declared AFTER the parameters because pascal habits die hard. It looked like a run of the mill structure declaration to me.

parent mikewarot 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton