[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc1) goto syntax
- From: David Manura <dm.lua@...>
- Date: Sat, 18 Jun 2011 00:48:50 -0400
On Thu, Jun 16, 2011 at 11:58 AM, Edgar Toernig <froese@gmx.de> wrote:
> In my experience, it helps reading and understanding code if the
> jump-statement gives a hint about the direction the jump takes,
> forward or backward.
Mike Pall's dynasm does that [1]. Labels are numeric (1: to 9:) and
can be reused. Forward (>) or backward (<) modifiers in the jump
opcodes disambiguate. When I first saw this syntax, it's purpose
wasn't immediately obvious to me.
An explicit forward/backward modifier in Lua goto would resolve the
lookup ambiguity I discussed in [2], but that can also be resolved
just by wrapping each for loop in a do/end block. Moreover, I'm not
sure the added noise is worth it. We don't have forward/backward
direction modifiers in function calls either:
function f() >g() end; function g() <f() end
If all gotos to a label are only above or below it, then you can name
the label in a way that will indicate the jump direction (which will
be obvious *both* on reading the goto or the label):
@ redo for x=1,10 do for y=1,10 do
if not f(x,y) then goto skip end
if not g(x,y) then goto redo end
end end @ skip
[1] http://repo.or.cz/w/luajit-2.0.git/blob/refs/heads/master:/src/buildvm_arm.dasc
[2] http://lua-users.org/lists/lua-l/2011-06/msg00772.html
- References:
- [ANN] Lua 5.2.0 (beta-rc1) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Alexandre Erwin Ittner
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Frank Meier-Dörnberg
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, David Kastrup
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Frank Meier-Dörnberg
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Eduardo Ochs
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Frank Meier-Dörnberg
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, David Given
- Re: [ANN] Lua 5.2.0 (beta-rc1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.0 (beta-rc1) goto syntax, Edgar Toernig