[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ¿Error in the reference manual?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 10 Mar 2010 14:23:21 -0300
> Hello,
>
> If I understand it properly, according to the grammar at the end of
> the reference manual,
> the following statement should be legal (although it isn't in practice):
>
> a = function() break end
>
> http://www.lua.org/manual/5.1/manual.html#8
>
> Here are the relevant entries:
>
> function ::= `function´ funcbody
> funcbody ::= `(´ [parlist] `)´ block `end´
> block ::= chunk
> chunk ::= {stat [`;´]} [laststat [`;´]]
> laststat ::= `return´ [explist] | `break´
>
> I'm a self thought programmer, so my grasp of theoretical CS is a bit
> hazy. Does the bug lie in the spec or in my mind?
Breaks can only appear inside loops. This is a "semantic restriction",
because it is too complicated to express this restriction in the
grammar. (A similar restriction is that the expression '...' can only be
used in vararg functions.)
-- Roberto