lua-users home
lua-l archive

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




On 06/06/15 06:33 PM, Rodrigo Azevedo wrote:
3.4.10 – Function Calls

The form

	functioncall ::= prefixexp ‘:’ Name args

Arguments have the following syntax:

	args ::= ‘(’ [explist] ‘)’
	args ::= tableconstructor
	args ::= LiteralString

can be used to call "methods". A call v:name(args) is syntactic sugar for v.name(v,args), except that v is evaluated only once.

-------------------

Let v be a usardata with a unary method, then

v:abs() is a syntatic sugar for v.abs(v)
v:reduce() is a syntatic sugar for v.reduce(v)

etc

This notation is very unpleasant. There is a problem if this behaviour of function calls

v:abs is a syntativ sugar for v.abs(v)
v:reduce is a syntatic sugar for v.reduce(v)

was valid?

Does v:abs() mean "call v.abs with v" or "call the result of calling v.abs with v"?

If not, I really appreciate this new flavor.

--
Rodrigo Azevedo Moreira da Silva

-- 
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.