lua-users home
lua-l archive

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



On Jun 11, 2015, at 10:56 PM, Thomas Jericke <tjericke@indel.ch> wrote:

Also your argument that function calls are clear is not true. Lua already drops the () for single string and single table arguments.

print "I am a call!"

So there are calls without a pair of (), and to make it worse there are a lot of (some stuff here) which aren't a call.
Now even I don't agree with the readability, I still don't think the introduction of a x:f syntax is necessary enough to add it to vanilla.

Because “foo” by itself is an rvalue that HAPPENS to yield a function. “Calling” the function is triggered NOT by the value in itself, but by the following token: parentheses, a table or a string.

x = foo
x = foo()
x = foo “bar”
x = foo {}

The first is clearly a simple assignment. The others are clearly not; the syntax following “foo” makes that clear and unambiguous. And currently that simple rule applies equally to “:”, so you have one rule to learn and that’s that. Your proposal adds more “special case” rules to the language, and you are on the path to the mess that is C++. It’s interesting to note that in Swift 2.0 just announced one of the changes was to back off from some of the confusing rules around compiler handling of parameter names (there were different rules for methods and functions, and people found them a mess). And again, as I noted, the “gain” is only avoiding typing a couple of parentheses.

—Tim