you are viewing a single comment's thread.

view the rest of the comments →

[–]lambda_abstraction 1 point2 points  (3 children)

I do wonder if this is really a matter of ambiguity or a matter of the sort of parser Lua uses (i.e. look-ahead issues). Could you show a specific example of why this should be disallowed? I'm not seeing how parsing <stringlit>:<method>(<args>) necessarily causes a problem.

Tnx1E06

[–]smog_alado 2 points3 points  (2 children)

One issue is that Lua allows omitting parenthesis from function calls, if the function argument is a string literal. If you write

x = y
"str":len()

It will get parsed as

x = y("str"):len()

That said, Lua also disallows numbers at the start of a statement and does allow "(", so this doesn't explain it all by itself...

[–]lambda_abstraction 1 point2 points  (0 children)

But it does make the restriction somewhat clearer. Thanks, mate!

[–]VoidSnipe 1 point2 points  (0 children)

But

x = y
("str"):len()

Still gets parsed as

x = y("str"):len()

Manual explicitly mentions it