2 ms·
It is a very good idea to write a small compiler for teaching purpose. However I think it would have been better to have clean code where the reader can underst
by p4bl0 14y ago
It is a very good idea to write a small compiler for teaching purpose. However I think it would have been better to have clean code where the reader can understand what happens at each line. Here the massive usage of global variables makes it harder and unintuitive. Also there are a lot of functions which returns for instance 0 or 1 to signal their success or failure but then at the call sites their return values are always ignored. Also, the way the ∗_expr functions works in the part 2 is really, really weird and unintuitive (but this is due to the all-in-global-variables design). I could go on with other issues, but all this is to point out the big caveat: one should not take the code of the article and try to grow the compiler to extend it because doing so will lead to horrible spaghetti code. And that really is too bad, because it would have been an even better exercise for beginners to extend such a small compiler.