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 will ask for a "strict" mode.
I'm well aware of this (see my original message) and would prefer using is_identical_function but as you said that wouldn't be consistent with the language.
For converting functions into opcodes - aren't there more relevant candidates? strlen() or such come to mind. And no, I won't make them constructs either.
You're right, there is a function that deserves even more to be in the core language: substr, probably the most used core function. In fact I also have a patch to add a new range constructor ":" and be able to use $string[:-4] or $array[2:5] instead of substr/array_slice. Expressions such as $x in 1:99 are also nice. However, this comes at the cost of a new base type. Although I think it's well worth it, I also like Pierre's idea:
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 implementation yet so far.
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?
That seems like a step in the right direction, with no change to the syntax required. I'll try to see if I can make an implementation of this but I fear it might be a bit more complex than just new language constructors.
With regards, Antoine Delignat-Lavaud -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php