as long as i remember the in operator was "raw" and did NOT employ delegation. I guess the documentation for "rawin" metamethod is simply wrong.
(BOTH should return false)
directly GETTING a value will emply delegation, so you can simply use a surrogate like
Code:
function delegate_in(needle,haystack)
{
try{
haystack[needle] ; //unless compiler optimizes such expressions away one day, this is a valid expression
return true ;
} catch (x) { }
return false ;
}
but you can't do it vice versa (emulate a non-delegate "in") without costly iterations. So the in operator is fine as it is.
I wouldn't change that behaviour but rather fix the docs about rawin (which erroneously suggest the "in" operator is employing delegation - which it definitely does not, should not, and it's documentation doesn't say anything explicit about it, but implicit it does... it tests "if a key is in a table". I wouldn't assume it's checking delegates by that wording).
Hence, the rawin default delegate is somewhat obsolete FOR TABLES. (it quite does make sense for classes and instances, where the 'in' operator is not available)