First, I just have to say what an amazing resource this is. Thanks!
But I do have two questions, the first of which has literally burned a hole in my brain since I read your tutorial: When you emit the instructions to the buffer, I noticed that you encode the objects(or at least the ints) beforehand. Why is this? I am specifically talking about about line 3 in compile_expr() in part 2. Am I misunderstanding something?
My second question is when you might be releasing a new part in the series ;)
1) Great question! This is because there is no type information in assembly. We have to build it ourselves. There are sort of two ways to do that: one is to have the compiler know everything ahead of time about what types registers/stack locations/etc all have. The other (which I chose to use) is dynamic typing, where the type information is somehow encoded into the object. In this case, the type information is encoded into the pointer. So when we generate instructions like "mov rax, <something>", we have to encode that the object is an integer.
2) Yeah, I know :( I had some life events in fall/winter that stopped all my motion on this series. I have a half-working closure implementation -- the actual closures are fine but the tree transformations are not yet implemented.
Ah, I see; I am not an expert in this field so it isn't really clear to me why that information would be needed; the assembly is already being emitted? Is it because functions that will take ints(which will inevitably recieve them from some kind of stack pop or similar) have to have the typing verified before their execution begins?
I hope your situation has improved/is improving; good luck! I love your website.
But I do have two questions, the first of which has literally burned a hole in my brain since I read your tutorial: When you emit the instructions to the buffer, I noticed that you encode the objects(or at least the ints) beforehand. Why is this? I am specifically talking about about line 3 in compile_expr() in part 2. Am I misunderstanding something?
My second question is when you might be releasing a new part in the series ;)