lua-users home
lua-l archive

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


On 04/29/2014 03:30 PM, Dirk Laurie wrote:
2014-04-29 14:49 GMT+02:00 Thomas Jericke <tjericke@indel.ch>:

require "string"
local text = "I can shout!"
print(text:upper) --> I CAN SHOUT!
Another plausible semantics for the same notation would be
specialization of the first argument (forgot the correct technical
term) so that `f = text:upper` means the same as

f = function(...) return text:upper(...) end

I don't really like the idea of function declarations that don't involve the 'function' keyword. But maybe I am just conservative here. I just think that having an explicit 'function' keyword
is actually an advantage of Lua over 'C' like programming languages.
Now would I be willing to sacrifice the syntax space for that
eventuality in favour of typing two characters fewer in the case
of a member function called with no arguments? That is the
question.

I am never in favour of changing things to type less (see my remark about the function keyword ^^ ), actually I think the syntax just becomes prettier without too many brackets. I also prefer 2*a + 3*b over (2*a) + (3*b), but I have to admit, it's just personal taste.
--
Thomas