The implementation described here is inspired by Lua. Even if you already know what a closure is, it might still be a worthwile read, since it probably implements them very differently from what you are thinking! Instead of always heap-allocating variables that are used by closures, it starts by stack-allocating them and only moves them to the heap if the closure outlives its parent function. In order for this to wor…
Another approach is to do the opposite - always store all local variables in the heap, and rely on scalar replacement of aggregates to put them back onto the stack where possible. This is what I do in my Ruby interpreter. That’s definitely not compatible with a single-pass though!
Crafting Interpreters: Closures
11–20 of 62 posts
Re: Crafting Interpreters: Closures
#12Re: Crafting Interpreters: Closures
#13Author here! Happy to answer questions, accept criticism, etc. :)
Re: Crafting Interpreters: Closures
#14Re: Crafting Interpreters: Closures
#15Does anyone know of any similar material that helps you create a database / distributed database from scratch?
Re: Crafting Interpreters: Closures
#16Re: Crafting Interpreters: Closures
#17Does anyone know of any similar material that helps you create a database / distributed database from scratch?
Here is a 13 part series on implementing a database: https://cstack.github.io/db_tutorial/
Re: Crafting Interpreters: Closures
#18Small piece of ui/ux feedback. It would be awesome if you moved the next and previous buttons to a static position so I can quickly page through the book. Right now they hop up and down.
I'll probably do some site tweaks after I finish the last chapter. In the meantime, the layout is quite responsive. If you make the window narrower, eventually you get to a single column layout with the navigation statically positioned on top.
Re: Crafting Interpreters: Closures
#19Author here! Happy to answer questions, accept criticism, etc. :)
I've been anticipating the Garbage Collection chapter (next on the list!) for quite some time! Do you have an estimated time frame for when it will be released? Thanks for the great book!
Me too! It's one of the chapters I've been most looking forward to writing. (This chapter on closures was another.)
> Do you have an estimated time frame for when it will be released?
Chapters take me roughly a month, but there's pretty high variance depending on what else is going on in my life. I work on it every day, but the amount of time per day varies. My hope is that it will get faster as I get closer to the finish line. It's been a long marathon, longer than I initially anticipated.
Re: Crafting Interpreters: Closures
#20Earlier quoted context omitted.
Any more gems like this you would recommend?
“Compiler Construction” by Niklaus Wirth (2014) [pdf] https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/... Modern Compiler Implementation in Java, C and ML. https://www.cs.princeton.edu/~appel/modern/ From Nand to Tetris https://www.nand2tetris.org/
The fact that he's still writing is kind of amazing. Besides him and Knuth, who from their generation of computer scientists are still active?