3 ms·
What this leaves me wondering is : what are the continuation semantics for the gotos? Without that part it's hard to know if "ill formed" gotos that result in
by carterschonwald 15y ago
What this leaves me wondering is : what are the continuation semantics for the gotos? Without that part it's hard to know if "ill formed" gotos that result in trying to execute expressions with undefined variables can happen or not.
- justincormack 15y agoA label is visible in the entire block where it is defined (including nested blocks, but not nested functions). A goto may jump to any visible label as long as it does not enter into the scope of a local variable. This can be determined statically.
- carterschonwald 15y agook, so the semantics for lua goto's is to enter at the start of smallest enclosing block that has no free variables in the current environment? Or to statically reject code that tries to do so? That doesn't sound quite accurate, unless you're saying that lua does some static analysis before execution, which I was not aware of.
- Dylan16807 15y agoLua compiles to a simple bytecode. It makes sure gotos are valid during this compilation. It jumps directly to the label, and can't skip forward over the declarations of variables that are in scope at the label.
- carterschonwald 15y agocool. Thanks for the info. Where are this and other features nicely documented?
- Dylan16807 15y agoI would suggest reading The Implementation of Lua 5.0 http://www.lua.org/doc/jucs05.pdf http://www.lua.org/doc/jucs05.pdf