|
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 |