Minor documentation inconsistency

206 views
Skip to first unread message

Martin Eden

unread,
Feb 5, 2026, 7:57:13 PMFeb 5
to lu...@googlegroups.com
Hello authors,

Looks like "global" declaration statement is put incomplete in
EBNF syntax section:

  https://lua.org/manual/5.5/manual.html#9

  stat ::=
    ...
    global attnamelist |
    ...

It should be

  global attnamelist ['=' explist] |

is the same manner as "local attnamelist".


Also I enjoy dedicated and comfortably dense style of this manual.

-- Martin

Roberto Ierusalimschy

unread,
Feb 7, 2026, 12:49:17 PMFeb 7
to 'Martin Eden' via lua-l
> Looks like "global" declaration statement is put incomplete in
> EBNF syntax section:
>
>   https://lua.org/manual/5.5/manual.html#9
>
>   [...]

Many thanks for the feedback.

-- Roberto

Peter Clayton

unread,
Jul 2, 2026, 8:41:34 PMJul 2
to lua-l
It seems like "global attnamelist" is also wrong in another way: When you don't supply the ['=' explist], it doesn't accept a spread attribute (first attribute shared between all declared values).
Invalid:
    global <const> varA, varB
Valid:
    global <const> varA, varB = 1,2
Valid:
    global varA<const> varB<const>

Also, it seems like it ignores the const-ness of global variables.
Valid:
    > global test<const> = 45
    > test = 23

What's up with that?

-- Peter

Roberto Ierusalimschy

unread,
Jul 6, 2026, 1:59:34 PMJul 6
to lu...@googlegroups.com
> It seems like "global attnamelist" is also wrong in another way: When you
> don't supply the ['=' explist], it doesn't accept a spread attribute (first
> attribute shared between all declared values).

Are you talking about the code or the documentation? Which version?


> Also, it seems like it ignores the const-ness of global variables.
> Valid:
> > global test<const> = 45
> > test = 23
>
> What's up with that?

Each line in the REPL is an independent chunk. The scope of 'global' goes
only until the end of the chunk (in that case, end of the line).

-- Roberto

Peter Clayton

unread,
Jul 6, 2026, 6:30:07 PMJul 6
to lua-l
> > It seems like "global attnamelist" is also wrong in another way: When you
> > don't supply the ['=' explist], it doesn't accept a spread attribute (first
> > attribute shared between all declared values).
>
> Are you talking about the code or the documentation? Which version?

I'm talking about the Lua 5.5 documentation: https://lua.org/manual/5.5/manual.html#9.

> Each line in the REPL is an independent chunk. The scope of 'global' goes
> only until the end of the chunk (in that case, end of the line).

That makes sense. Maybe a warning would be nice though. Locals say "warning: locals do not survive across lines in interactive mode", and something similar would work, but it should also mention how it's just the restriction of access to globals that doesn't survive, while declaring globals with values assigned does also declare them in a way that makes them persist across lines.

-- Peter

Roberto Ierusalimschy

unread,
Jul 10, 2026, 10:29:18 AM (14 days ago) Jul 10
to lu...@googlegroups.com
> > > It seems like "global attnamelist" is also wrong in another way: When
> you
> > > don't supply the ['=' explist], it doesn't accept a spread attribute
> (first
> > > attribute shared between all declared values).
> >
> > Are you talking about the code or the documentation? Which version?
>
> I'm talking about the Lua 5.5 documentation:
> https://lua.org/manual/5.5/manual.html#9.

The documentation there says this:

stat ::= [...] | global attnamelist
attnamelist ::= [attrib] Name [attrib] {‘,’ Name [attrib]}
attrib ::= ‘<’ Name ‘>’

As already pointed out, it misses the optional ['=' explist]. Apart from
that, 'attnamelist' starts with the "spread attribute".

-- Roberto
Reply all
Reply to author
Forward
0 new messages