Interesting things about the Lua interpreter (2020)
thesephist.com
Interesting things about the Lua interpreter (2020)
1–10 of 44 posts
Re: Interesting things about the Lua interpreter (2020)
#2Re: Interesting things about the Lua interpreter (2020)
#3Re: Interesting things about the Lua interpreter (2020)
#4This is a common source of confusion, because the name "register machine" makes people think about CPU registers. However, the registers in a register VM are merely slots in the traditional runtime stack. The difference between a stack and register machine has to do with how the bytecode instructions are encoded. In a stack machine, most instructions implicitly pop arguments from and push their results to the top of the stack. The instructions are byte-sized, encoding just the operation name. For example, to add 10+10
LOADK 10
DUP
ADD
Meanwhile, in a register machine the instructions can read and write to any slot in the stack. Instructions are larger, because in addition to the operation name they also encode the indexes of the input slots and the index of the output slot. But it's worth it because you need less instructions in total and do less stack shuffling. LOADK 1 10
ADD 1 1 2Re: Interesting things about the Lua interpreter (2020)
#5I love that they went from a single-pass interpreter to a byte-code virtual machine, and now like PHP, also has direct access to C & system libraries! Lua has come a long way since it's advent.
Re: Interesting things about the Lua interpreter (2020)
#6The Lua interpreters, "upvalues" sound suspiciously like the results of Tcl's, "upvar", can anybody comment on how similar they actually are?
If you want all the gritty details, a chapter of Crafting Interpreters walks through a complete implementation of Lua's approach to closures:
Re: Interesting things about the Lua interpreter (2020)
#7It's still a really insightful and approachable paper that's worth reading, and it does still help understand the constraints and approach of lua. But the current "old" version of the language is 5.2 released in 2011, and there have been a couple major versions after that as well.
So some of it may not actually be applicable to using lua now, depending on what your "now" looks like.
Re: Interesting things about the Lua interpreter (2020)
#8The Lua interpreters, "upvalues" sound suspiciously like the results of Tcl's, "upvar", can anybody comment on how similar they actually are?
I don't think there's any deep connection. "upvar" in Tcl is a language feature. Upvalues in Lua are purely an implementation detail of the interpreter. If you want all the gritty details, a chapter of Crafting Interpreters walks through a complete implementation of Lua's approach to closures: http://craftinginterpreters.com/closures.html
They aren't the same thing but they are closely related concepts and similar solutions to the same potential problem.
Re: Interesting things about the Lua interpreter (2020)
#9The Lua interpreters, "upvalues" sound suspiciously like the results of Tcl's, "upvar", can anybody comment on how similar they actually are?
Re: Interesting things about the Lua interpreter (2020)
#10Timing on this is confusing. Article was written in 2020 about a paper published in 2003 or so about the design of lua 5.0. It's still a really insightful and approachable paper that's worth reading, and it does still help understand the constraints and approach of lua. But the current "old" version of the language is 5.2 released in 2011, and there have been a couple major versions after that as well. So some of it…