Hi!

> Agree, but maybe a RFC for "in" operator and a follow up RFC to allow
> "in" on "for" context could be a win/win here as long as one feature
> doesn't block each other?

The problem is "in" is not just "for". The problem is this: when you say
"$foo in $bar", is $foo a value or a key? In many languages, $foo would
be a value for a list (and a vector) and a key for a map, but in PHP
lists, vectors and maps are the same data type, so you can not implement
it in the same way as, say, in Python. I.e. in Python:

>>> 1 in [1,2,3]
True
>>> 1 in {1:'a',2:'b',3:'c'}
True
>>> 1 in {'a':1, 'b':2, 'c':3}
False
>>> 5 in [5,6,7]
True
>>> 5 in {0:5,1:6,2:7}
False


In PHP, even if it'd be possible to implement such semantics (which I'm
not sure), it would be very confusing and hard to explain.

-- 
Stas Malyshev
smalys...@gmail.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to