lua-users home
lua-l archive

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


> > Is there any reason why __eq is not called when the metatable is shared for a
> > type other than table and userdata?
> > 
> > [...]
> > > print(3==4)
> > false
> 
> Isn't this reason enough?

Not for me (not that I would define __eq for numbers; this is just an
example). What about functions? I can understand why you don't have individual
metatables for functions, but why not __eq? From the point of view of
"providing mechanisms, not policies", it seems weird to decide for the user if
he should or not define __eq for a certain type.

Anyway, I just think that if this is a reason for the authors, it should be at
least stated in the manual. And, as I said, since we were talking about __len
being honored for tables, I'm all for __eq (and other comparisons for that
matter) being more "consistent". 

Cheers,
Luis.

-- 
A mathematician is a device for turning coffee into theorems.
        -- P. Erdos 

-- 
Luis Carvalho
Applied Math PhD Student - Brown University
PGP Key: E820854A <carvalho@dam.brown.edu>