Unclear grammar for global in 5.5
Sergey Bronnikov <[email protected]> Thu, 16 Jul 2026 04:16:34 -0700 (PDT)
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_418184_826899879.1784200594599 Content-Type: multipart/alternative; boundary="----=_Part_418185_658582381.1784200594599" ------=_Part_418185_658582381.1784200594599 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, Lua 5.5 BNF grammar contains rules for "local" and "global" names: stat ::=3D =E2=80=98;=E2=80=99 |=20 <snipped> local attnamelist [=E2=80=98=3D=E2=80=99 explist] |=20 global attnamelist | <snipped> I'm confused by the absence of the "[=E2=80=98=3D=E2=80=99 explist]" in the= rule for "global". It seems that the code below is syntactically incorrect: global a, b =3D 1, 2 or=20 global a =3D 1 or global <const> a =3D 1 However, the chunks above are successfully accepted by Lua: $ ./lua -e "global a, b =3D 1, 2"; echo $? 0 $ ./lua -e "global a =3D 1"; echo $? 0 $ ./lua -e "global <const> a =3D 1"; echo $? 0 Where is a truth? Also, it is suspicious that chunk below does not work: $ ./lua -e "global a; print()" ./lua: (command line):1: variable 'print' not declared The same with "local" works fine: $ ./lua -e "local a; print()"; echo $? 0 Version: PUC Rio Lua 5.5, 84938a7d2b680d2d28ec99606e84fe712efd9a69 1. https://www.lua.org/manual/5.5/manual.html#9 --=20 You received this message because you are subscribed to the Google Groups "= lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/02a5a= 793-15d3-4a40-8e52-5fc1f2cad7b6n%40googlegroups.com. ------=_Part_418185_658582381.1784200594599 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div>Hello,</div><div><br /></div><div>Lua 5.5 BNF grammar contains rules f= or "local" and "global" names:</div><div><br /></div><div><span style=3D"wh= ite-space: pre;"> </span>stat ::=3D =C2=A0=E2=80=98;=E2=80=99 | <br /><s= nipped><span style=3D"white-space: pre;"></span><br /><span style=3D"whi= te-space: pre;"> </span>=C2=A0local attnamelist [=E2=80=98=3D=E2=80=99 exp= list] | <br /><span style=3D"white-space: pre;"> </span>=C2=A0global attna= melist |</div><div><snipped><span style=3D"white-space: pre;"></span>= </div><div><br /></div><div><span lang=3D"en"><span><span>I'm confused by t= he absence of the "</span></span></span>[=E2=80=98=3D=E2=80=99 explist]<spa= n lang=3D"en"><span><span>" in the rule for "global".</span></span></span><= /div><div><span lang=3D"en"><span><span>It seems that the code below is syn= tactically incorrect:</span></span></span></div><div><span lang=3D"en"><spa= n><span><br /></span></span></span></div><div>global a, b =3D 1, 2</div><di= v>or=C2=A0</div><div><span>global a =3D 1</span></div><div><span>or</span><= /div><div><span>global <const> a =3D 1</span></div><div><span><br /><= /span></div><div><span>However, the chunks above are successfully accepted = by Lua:</span></div><div><span><br /></span></div><div>$ ./lua -e "global a= , b =3D 1, 2"; echo $?<br />0<br />$ ./lua -e "global a =3D 1"; echo $?<br = />0<br />$ ./lua -e "global <const> a =3D 1"; echo $?<br />0<br /><br= /></div><div>Where is a truth?</div><div><br /></div><div>Also, it is susp= icious that chunk below does not work:</div><div><br /></div><div>$ ./lua -= e "global a; print()"<br />./lua: (command line):1: variable 'print' not de= clared<br /><br /></div><div>The same with "local" works fine:</div><div><b= r /></div><div>$ ./lua -e "local a; print()"; echo $?<br />0<br /><br /></d= iv><div>Version: PUC Rio Lua 5.5,=C2=A084938a7d2b680d2d28ec99606e84fe712efd= 9a69</div><div><br /></div><div>1.=C2=A0https://www.lua.org/manual/5.5/manu= al.html#9</div> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups &= quot;lua-l" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:[email protected]">lua-l+unsubsc= [email protected]</a>.<br /> To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/= lua-l/02a5a793-15d3-4a40-8e52-5fc1f2cad7b6n%40googlegroups.com?utm_medium= =3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/lua-l/02a5a= 793-15d3-4a40-8e52-5fc1f2cad7b6n%40googlegroups.com</a>.<br /> ------=_Part_418185_658582381.1784200594599-- ------=_Part_418184_826899879.1784200594599--