[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Custom "comparison for equality" in Lua ?
- From: Didier Guillion <didier@...>
- Date: Fri, 3 Jan 2003 10:43:13 +0100
In Lua 4.0 I read it is already possible to write a custom "ordered
through the "lt".
Is it a way to write a custom "equal" function ?
Let's take an example :
Let's say I want to implement a "complex number" data type.
It is made of a table, with two indexes "r" and "i"
How can I let the lua interpreter make :
if a==b then print("equality") end
run as expected (i.e. print "equality") ?
Please consider I do not need a trick to implement complex numbers only.
It is just an
The object type I need actually to implement is much more complicated,
with its own
tag and tag methods. I know how to compare such objects for equality, but
I could not
find a way to trap the comparison, except by rewriting the
"LuaO_EqualObj" in the Lua
Thanks in advance for any advice or comment.