lua-users home
lua-l archive

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


On 29 April 2014 20:49, Thomas Jericke <tjericke@indel.ch> wrote:
The first change is simple and I have already a patch for it, I can release it as single patch if someone is interested.
This change simply makes the function call brackets optional if there is no argument, other than self which is implicitly added.
This means you can write:
require "string"
local text = "I can shout!"
print(text:upper) --> I CAN SHOUT!

I think this change is quite useful for the following reasons:
- No ambiguity: The : operator outside a function declaration like "function table:funct() ... end" already defines a function call, no need to define it twice with empty brackets.

I disagree here.  If you encounter foo:bar() in text now, does it mean foo.bar(foo) or does it mean foo.bar(foo)()?  (Keep in mind that bar can return a function after all.)

To me this seems to be ambiguous, meaning you have to have some arbitrary rule to determine which meaning is intended.  I prefer explicit behaviour than implicit behaviour surrounded by arbitrary rules.
 
Anyway, with the first step already done I am now trying to handle the "hello":function and 1.6:function to work.

I am not sure how much I want to allow. Especially in this case:
print( lower "I'm getting loud with you !" : upper)

What should happen? Synstax error, print "I'M GETTING LOUD WITH YOU!", or "i'm getting loud with you!"?

As soon as you find yourself asking this question in a language design, personally I think it's time to back out and look at your goals.  No matter how you answer this you're adding unnecessarily (IMO) to the cognitive load of the user in exchange for dubious statements about "readability" (when you actually likely mean "ease of typing" since programmers typically have a fetish for not typing for some reason).

--
"Perhaps people don't believe this, but throughout all of the discussions of entering China our focus has really been what's best for the Chinese people. It's not been about our revenue or profit or whatnot."
--Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.