lua-users home
lua-l archive

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


On Fri, Sep 3, 2010 at 12:49 AM, Stefan Behnel <stefan_ml@behnel.de> wrote:
> Is that the expected behaviour? Is there a way to define a metatable only
> for a specific C function?

Only tables and full-userdata can have their own individual
metatables. For other types, one metatable is shared amongst all
instances of a given type. You could think of this as because tables
and userdata let you define your own types, each with its own
metatable. It doesn't make sense to assign a metatable to just the
integer 42, and not any others. Likewise, functions always behave the
same: you call them and they do stuff.

Maybe you could set the __ call metamethod on your userdatum's metatable?

~Jonathan