lua-users home
lua-l archive

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


> Since tables are comapered 'by reference' (something I agree with) it
> would be handy to have a function wich would compare two tables 'by
> value'. I searched the archives and didn't come up with any
> requests/questions on this subject, wich I though was kind of strange.
> Anyway I'm sure there are complications wich escape me right now but
> how come there's nothing like that in the table library?

I guess there's no canonical way to do it.  Must metatables coincide or be
equal?  Do you want to compare "inherited" keys as well?  Do you compare
member tables by reference or by value?  As someone pointed out some time
ago, equality for closures is impossible to handle other than by reference.
So what to do with member closures in an equality test?  Userdata?  etc.

Letting you design your own tests is probably the best way to handle this.
(The same approach is taken in C++ for example.)

Bye,
Wim