lua-users home
lua-l archive

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


On Tue, Feb 21, 2017 at 3:20 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2017-02-21 11:03 GMT+02:00 Francisco Olarte <folarte@peoplecall.com>:
> Would you have been happier with the previous version of that section?
...snip....
>     https://www.lua.org/manual/5.2/manual.html#2.4

mmmm, NO, in principle, at least for the "call" description.

In this case the pseudocode in "call" would make me think a callable
should work. I would be happier if the pseudocode stated <if h and
type(h)=="function">, after all this is easy to put in the seudocode.

Also in the header it says "For instance, when a non-numeric value is
the operand of an addition, Lua checks for a function in the field
"__add" of the value's metatable. If it finds one, Lua calls this
function to perform the addition. " like the present one, but I
suspect specifically __add does not need a real function, as it
happens in 5.3.

But anyway I would have to thoroughly compare the two sections before
giving an informed opinion. I think either version could be fine, but
it must be stated that __call MUST be a real function and, if callable
things work for the other metamethods but not by design but because
that is "undefined behavior" and calling the object is the choice for
it state it too ( so people do not rely on it for non trivial code
intended to work in several lua versions ).

I think many people, specially if coming from other languages, may
think as me, and get confused too.

Thanks.
  Francisco Olarte.