
On Tue, Jun 9, 2020 at 8:08 PM Guido van Rossum <guido@python.org> wrote:
I believe there are some other languages that support a similar grammar (Ruby? R? Raku?) but I haven't investigated.
Lua has a similar feature: a name (including a dotted name or index[ing], which are identical in Lua) immediately followed by a string literal or table literal is syntactic sugar for calling the named function/callable with that string or table as its only argument. This is commonly used with print() and require(), and also is sometimes used (with table literals) to simulate calling a function with named arguments. Lua allows this to be chained: for example, the line `require "math" "test"` is the same as `require("math")("test")`, calling the result of `require("math") with the argument "test". (Incidentally, `require "math"` returns a non-callable table, so actually running that will generate an error message saying "attempt to call a table value". So it's a bad example, but there are legitimate use cases for this.) However, Lua only supports this for single arguments (two or more require the parentheses) and only for an argument that is a string literal or table literal, nothing else (in particular, numbers and names require the parentheses).