News for hackers. Stuff that matters.
Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by telemachos on Saturday December 31, 2011 @10:37AM (#3411047)
The attitude towards goto really struck a chord with me. It's "powerful" and "easy to explain". It's also "simple" to add to the VM. It's in, and purity be damned.

There's something to be said here about pragmatism versus purity. Maybe also a comparison with the recent posts about OO and Rails. I'm hand-waving. I mean to write something longer about this, but I'm still trying to decide what exactly I make of it.

Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by justincormack on Saturday December 31, 2011 @01:10PM (#3411418)
A lot of people wanted it is Lua is quite widely used as a code generation target, and generating gotos is useful often to match other language constructs.
Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by watmough on Saturday December 31, 2011 @10:39AM (#3411051)
For anyone wondering about "C upvalues", which wasn't clear to me, there is some explanation here:

http://www.lua.org/pil/27.3.3.html

Essentially, they are unbound variables that have to be reachable from the function by some mechanism, making it a closure.

Apologies if I've misunderstood anything here.

Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by zeen on Saturday December 31, 2011 @02:09PM (#3411561)
You got it. Quoting from the 5.2 manual:

  Because of the lexical scoping rules, local variables can
  be freely accessed by functions defined inside their scope.
  A local variable used by an inner function is called an
  upvalue, or external local variable, inside the inner
  function.
i.e., the external local variables the closure is closed on. And for C functions made available to Lua scripts:

  When a C function is created, it is possible to associate
  some values with it, thus creating a C closure (see
  lua_pushcclosure); these values are called upvalues and are
  accessible to the function whenever it is called.
- http://www.lua.org/manual/5.2/manual.html
Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by zura on Saturday December 31, 2011 @12:38PM (#3411348)
I think it is worth to mention:

Structured programming with go to statements (1974) by Donald E. Knuth (http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.103.6...)

Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by carterschonwald on Saturday December 31, 2011 @12:04PM (#3411250)
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.
Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by justincormack on Saturday December 31, 2011 @01:11PM (#3411423)
A 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.

Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by carterschonwald on Saturday December 31, 2011 @02:34PM (#3411618)
ok, 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.
Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by Dylan16807 on Saturday December 31, 2011 @02:43PM (#3411642)
Lua 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.

Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by carterschonwald on Sunday January 01, 2012 @10:07PM (#3414611)
cool. Thanks for the info. Where are this and other features nicely documented?
Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by Dylan16807 on Monday January 02, 2012 @01:37PM (#3416817)
I would suggest reading The Implementation of Lua 5.0

http://www.lua.org/doc/jucs05.pdf

Re:The Novelties of Lua 5.2 Roberto Ierusalimschy (pdf slide... by andrewcooke on Saturday December 31, 2011 @12:28PM (#3411322)
can someone smarter than me comment on whether delimited continuations are better or worse than goto and/or "ordinary" continuations? (because i suspect they are nicer in how they handle scope, and they are what are typically implemented, aren't they?)