[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: "attempt to compare number with userdata"
- From: Nikolai Kondrashov <Nikolai.Kondrashov@...>
- Date: Mon, 24 Nov 2008 18:26:30 +0300
Jan de Vos wrote:
> I think the only reason is that it protects you from easy-to-make
> mistakes. For instance, which metamethod do you want to use when the
> left hand side of the inequality is the number? Should the '<'
> class-metamethod for 'number' handle all the different kinds of userdata
> types you want to compare to? The requirement that both sides be of the
> same type makes such problems go away.
Thank you. It could be that I'm not very sharp today (or maybe ever), but
why comparison handling is different from arithmetic handling? I.e. why
should we use "getcomphandler" and not "getbinhandler"?
> If you really want to change it, look at lvm.c, specifically, the
> luaV_execute function (the cases for OP_LT etc), and further on the
> luaV_lessthan function and its friends.
Thanks :)! Though I'm not sure now, if I should change it.