[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Goto and return ('end' expected)
- From: Parke <parke.nexus@...>
- Date: Wed, 6 May 2015 09:51:36 -0700
On Wed, May 6, 2015 at 9:22 AM, Hisham <h@hisham.hm> wrote:
> The point is not how to workaround this. Aapo's question still stands.
In other languages where return is a statement, when debugging I often
insert returns mid-function to disable functionality. I assume the
Lua requires return at the end of blocks to avoid confusion:
function foo ()
a ()
b ()
return
c () -- foo will return c()
d ()
end
If you wanted to allow labels after returns, you would need to modify
Lua's grammar.
http://www.lua.org/manual/5.3/manual.html#9
block ::= {stat} [retstat]
retstat ::= return [explist] [‘;’]
Would need to become something like:
block ::= {stat} [retstat] [label]
Or possibly:
block ::= {stat} [retstat] {label}
This would not cause confusion similar to the above, as labels are not
expressions.
I would not oppose such a change.
-Parke