[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __call?
- From: Gustavo Niemeyer <niemeyer@...>
- Date: Tue, 16 Dec 2003 13:46:26 -0200
> The __call metamethod allows a table to be used as a function. This
> is similar to C++'s operator () for overloading the function call
> operator on objects.
[...]
As an interesting point, it should be noticed that callable objects
unfortunately are not real functions, and any code that tests for a
function type fails to detect the callable object. For example,
table.foreach() can't receive a callable object as the second
argument.
I've noticed problems like this while working on Lunatic Python. I ended
up implementing the __call method, but also wrapping Python functions
and methods in real Lua function closures, overwhelming these problems.
--
Gustavo Niemeyer
http://niemeyer.net