|
|
|
|
|
by Joker_vD
1038 days ago
|
|
Yes, and you can also just use parallel arrays of ints (or of constant-sized arrays of ints), because who needs structs with fields, really? #define NUM 0
#define BOOL 1
#define VAR 2
#define IF 3
#define LAM 4
#define APP 5
int nodes[MAX_NODES][4];
int next_node;
int mkIf(int condExp, int thenExp, int elseExp) {
assert((condExp < next_node) && (thenExp < next_node) && (elseExp < next_node));
nodes[next_node][0] = IF;
nodes[next_node][1] = condExp;
nodes[next_node][2] = thenExp;
nodes[next_node][3] = elseExp;
return next_node++;
}
Need additional data to stick to a node? Declare another array of MAX_NODES length and put it there! That's how Real Programmers wrote compilers in the seventies because real programmers write FORTRAN. |
|
What are you even making fun of?