Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-14 Thread Pierre Joye
On Mon, Nov 14, 2011 at 7:27 AM, Rasmus Lerdorf wrote: > It could also easily be a step in the wrong direction if it isn't > implemented carefully. Turning interchangeable scalar types into fake > objects could introduce the equivalent of strong typing. Indeed, that's not an easy thing to think

Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-13 Thread Rasmus Lerdorf
On 11/13/2011 10:08 AM, Pierre Joye wrote: > 2011/11/13 Antoine Delignat-Lavaud : >> So this means being able to use $string->strlen() (or even $string->len()) >> instead of strlen($string) or $array->in_array($x) ($array->in($x)) instead >> of in_array($x,$array), right? > > Yes, that's the idea,

Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-13 Thread Martin Jansen
On 13.11.11 19:08, Pierre Joye wrote: > 2011/11/13 Antoine Delignat-Lavaud : >> On Sun, 2011-11-13 at 14:23 +0100, Pierre Joye wrote: >>> >>> There is an idea to have pseudo object for common types, where these >>> functions would be callable without actually having an instance. No >>> implementati

Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-13 Thread Pierre Joye
2011/11/13 Antoine Delignat-Lavaud : > On Sun, 2011-11-13 at 03:10 +0100, Johannes Schlüter wrote: please use two replies next time :) > On Sun, 2011-11-13 at 14:23 +0100, Pierre Joye wrote: >> >> There is an idea to have pseudo object for common types, where these >> functions would be callable

Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-13 Thread Antoine Delignat-Lavaud
On Sun, 2011-11-13 at 03:10 +0100, Johannes Schlüter wrote: Your using is_equal_function, this does a == comparison. People will stumble over $a = 0; $a in ["a", "b", "c", "it's easy as one two three"]; which will be true. This is the consistent and correct behaviour for the language but people w

Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-13 Thread Pierre Joye
2011/11/13 Johannes Schlüter : > On Sun, 2011-11-13 at 03:10 +0100, Johannes Schlüter wrote: >> For 5.5 I also have doubts whether it's worth the additional keyword and >> opcode. Yes it will, most likely, but this is an extension to the >> grammar ... > > I meanwhile did a quick check on google co

Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-13 Thread Johannes Schlüter
On Sun, 2011-11-13 at 03:10 +0100, Johannes Schlüter wrote: > For 5.5 I also have doubts whether it's worth the additional keyword and > opcode. Yes it will, most likely, but this is an extension to the > grammar ... I meanwhile did a quick check on google codesearch. I found a few cases where "in

Re: [PHP-DEV] [PATCH] Making in_array a language operator

2011-11-12 Thread Johannes Schlüter
Hi, On Sun, 2011-11-13 at 02:37 +0100, Antoine Delignat-Lavaud wrote: > > if(($v1=="a1" || $v=="a2" || ...) && ($v2=="b1" || $v2=="b2" ||...) > && ...) This could also be written as if (in_array($v1, ["a1", "a2", ...]) && in_array($v2m ["b1", "b2", ...])) > by replacing them with: > > if($v