lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2014-04-29 16:59 GMT+02:00 Daurnimator <quae@daurnimator.com>:
> We already have that ambiguity:
>
> s = "I can shout!"
> u = s:upper()
>
> ("hello"):gsub(".",print)
>
> Could either mean
>   - assign "I CAN SHOUT!" to u, print each letter of "hello"
>   - call "I CAN SHOUT!" with "hello" and print the resulting letters

The ambiguity, and how to resolve it, is well documented in the
manual (§3.3.1 Blocks). It is specifically stated that the second is
what the parser does. (In some earlier Lua, I think it was resolved
by that empty line.)

However, in interactive mode, the first applies. The manual says:

| In interactive mode, if you write an incomplete statement, the interpreter
| waits for its completion by issuing a different prompt.

Maybe the manual could add a cross-reference to `§3.3.1 Blocks` at
that point.