Object Model Reformation – elementIn?

# Axel Rauschmayer (14 years ago)

strawman:object_model_reformation

Currently, there one can override the built-in operators via elementGet (getting via []), elementSet (setting via []) and elementDelete (delete operator). Wouldn’t it make sense to also provide elementIn (in operator)?

# Allen Wirfs-Brock (14 years ago)

On Jan 1, 2012, at 5:54 AM, Axel Rauschmayer wrote:

strawman:object_model_reformation

Currently, there one can override the built-in operators via elementGet (getting via []), elementSet (setting via []) and elementDelete (delete operator). Wouldn’t it make sense to also provide elementIn (in operator)?

Probably. It may depend upon how strongly you feel about obsoleting for-in in favor of for-of.

# Axel Rauschmayer (14 years ago)

Currently, there one can override the built-in operators via elementGet (getting via []), elementSet (setting via []) and elementDelete (delete operator). Wouldn’t it make sense to also provide elementIn (in operator)?

Probably. It may depend upon how strongly you feel about obsoleting for-in in favor of for-of.

That would be some kind of iteration protocol(?) I’d be perfectly happy with not supporting for-in at all.

I was thinking about the relational operator in:

if (key in myMap) {
    ...
}

if (element in mySet) {
    ...
}