lua-users home
lua-l archive

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




If "foo:bar" were a call, then why "foo" would not be a call? In Basic
and Pascal, "foo" is a call, if foo has no arguments.


1) The definition of : *implies* foo as an argument of bar, and () abstract a call of bar. [PROPOSAL] If you do not need an extra argument then : can also abstract a call, with the same foo argument as before.

2) foo is not a call because it needs *nothing* arguments! in Lua, as : *implies* at least one argument, you need to use the suffix () (the unique way to pass nothing and abstract a call). [PROPOSAL] On the other hand, it is nonsense to do :foo because blanks are mainly ignored (be definition) and is different of *nothing* [1], then you can't pass *nothing* this way.

3) In Lua, the "method" view in only a syntactic sugar and the absence of arguments (in the sense of (), {}, "") in foo:bar is obviously abstract since an operator is defined to operate on something, consequently bar needs at least one argument to the call, and this is exactly what : implies.
 
[1] strictly speaking :foo can be as valid as foo(), as well as :foo() since foo will be called with nothing anyway (assuming blanks ignored). But I think this over abstraction that will change the actual whole panorama. I would want to improve the map foo.bar(foo) to foo:bar() that just have a specifically definition in Lua, and improve the read on some cases. Maybe a second proposal with a real change to Lua :) (I really like this ideia).



--
Rodrigo Azevedo Moreira da Silva