[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Syntactical ugliness - does it matter?
- From: Matthew Wild <mwild1@...>
- Date: Wed, 5 Jun 2019 16:07:21 +0100
On Wed, 5 Jun 2019 at 15:59, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
>
> On Wed, 5 Jun 2019 at 15:53, Matthew Wild <mwild1@gmail.com> wrote:
> > $ cat resource.lua
> > local resource x = 5
> > print(resource, x)
> >
> > $ lua5.3 resource.lua
> > nil 5
> >
>
> Okay, I am a bit puzzled. The grammar says:
>
> local namelist [‘=’ explist]
>
> namelist ::= Name {‘,’ Name}
>
> So what you showed appears invalid grammatically ... but the parser allows it?
The Lua grammar is not line-based. Usually these two statements would
be written:
```
local resource
x = 5
```
But Lua would also accept it as:
```
local
resource
x
=
5
```
with the exact same semantics. Check luac -l if it helps.
The proposal of how to handle 'resource' as a semi-keyword would
change the meaning of this block of code, however it was written.
Designing language syntax is not trivial :)
Regards,
Matthew
- References:
- Syntactical ugliness - does it matter?, Dibyendu Majumdar
- Re: Syntactical ugliness - does it matter?, Pavel
- Re: Syntactical ugliness - does it matter?, Oliver Kroth
- Re: Syntactical ugliness - does it matter?, Ulrich Schmidt
- Re: Syntactical ugliness - does it matter?, Sergey Zakharchenko
- Re: Syntactical ugliness - does it matter?, Rodrigo Azevedo
- Re: Syntactical ugliness - does it matter?, Egor Skriptunoff
- Re: Syntactical ugliness - does it matter?, Dibyendu Majumdar
- Re: Syntactical ugliness - does it matter?, Ryan Ford
- Re: Syntactical ugliness - does it matter?, szbnwer@<a href="/cgi-bin/echo.cgi?gmail.com">...</a>
- Re: Syntactical ugliness - does it matter?, Matthew Wild
- Re: Syntactical ugliness - does it matter?, Dibyendu Majumdar
- Re: Syntactical ugliness - does it matter?, Matthew Wild
- Re: Syntactical ugliness - does it matter?, Dibyendu Majumdar
- Re: Syntactical ugliness - does it matter?, Matthew Wild
- Re: Syntactical ugliness - does it matter?, Dibyendu Majumdar
- Re: Syntactical ugliness - does it matter?, Matthew Wild
- Re: Syntactical ugliness - does it matter?, Dibyendu Majumdar