[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [PROPOSAL] [PATCH] simple method call
- From: Paige DePol <lual@...>
- Date: Fri, 12 Jun 2015 19:20:42 -0500
Tim Hill <drtimhill@gmail.com> wrote:
>> 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
This is a nice concise explanation of the issue at hand, thanks Tim!
Personally, I don't like the lack of ()'s for single string/table parameters either as I do like my calls to look like calls. I also plan to add named parameters to Lunia, which will probably necessitate the removal of the single string/table call syntax without parentheses anyways.
As for Swift, well I really was not a fan of the new syntax style... I liked my square brackets! However, I am happy to hear they are refining the language more and it will is something I will have to look at in more detail, but first I have to finish Lunia!
~Paige