Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Well Lisp can reflect on its objects! You can have code like:

(int? foo)

that returns #t or #f depending on if foo is an int. So `int?` needs to have information from somewhere about what type of object it is.

I get more into this in Part 4 (unary primitives).

Thanks :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: