[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: __call metamethod, misleading doc or am I missing something?
- From: Francisco Olarte <folarte@...>
- Date: Tue, 21 Feb 2017 10:18:46 +0100
On Tue, Feb 21, 2017 at 8:26 AM, Tim Hill <firstname.lastname@example.org> wrote:
> If I understand the OP correctly, he is saying that __add() will accept a callable, so why not __call()?
Well, the OP just was saying that it should be made clearer in the
The reason for not accepting a callable in __call is more or less
obvious to me, __add does not need "recursion" to accept a callable,
> I haven’t tested this but *if* he is correct,
IIRC I tested it and included the test in my message. True, it was
5.3.3 which I had at hand, not the latest and greatest but nothing in
the rel notes hints at this behaviour having changed.
> then that appears to differ from the Lua reference 2.4 that says "Note that queries for metamethods are always raw; the access to a metamethod does not invoke other metamethods.” So either he is wrong, the Lua ref manual is wrong, or the Lua code is wrong (I’m not taking bets here!).
IMO raw or normal access does not play. In fact I introduced an
example with a metamethod using a callable object, on normal (
raw==unraw access ). The thing is once you have accessed the
metamethod for __add ( ithout invoking others ) yout have to call the
value you got, but the access is over. Or not, if you define access
other way, but it does have nothing to do with rawnes.