Hi,
Where can I read what happens when I send a message to
an object
that does not implement the message sent?
e.g. cases like:
({123}):messageNotUnderstood()
Method calls (object:method()) is a shorthand for two
simpler operations: indexing a table and calling a
function.
object:method(args) is really:
local m = object["method"]
m(object, args)
Your example code is equivalent to:
local t = {123}
local m = t["messageNotUnderstood"] -- this is nil
because the method does not exist
m(t) -- passing the object to the nonexistent
'method'
You end up calling 'nil', which is what the
interpreter complains about:
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> ({123}):messageNotUnderstood()
stdin:1: attempt to call a nil value (method
'messageNotUnderstood')
stack traceback:
stdin:1: in
main chunk
[C]: in ?
See section 3.4.10 of the Lua 5.3 manual. "A call
v:name(args) is syntactic sugar for
v.name(v,args),
except that v is evaluated only once."
Hope that clarifies things.