On 11/13/2011 10:08 AM, Pierre Joye wrote: > 2011/11/13 Antoine Delignat-Lavaud <antoine.delignat-lav...@ens-cachan.fr>: >> 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, but then with obvious names: > > $string->length(); or $string->length; > $array->in($x); > > instead of reusing the horrible string functions we have right now > (needle haystack orders and other (impossible to remember) funny > things ;). > >> 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.
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. Doing: $a=12; echo strlen($a); and getting 2 shouldn't suddenly break if you do it using $a->length() which means all scalar fake object methods would be available on all scalar objects regardless of their type. Otherwise it is just a sneaky way of introducing strict typing and that would cause a lot of pain for a lot of people. And while I know I floated the idea myself a while back, I'm not a fan of scalar objects at all. It's not like it cleans up the global namespace any, and given the requirement to maintain interchangeable basic scalar types it doesn't even provide clean per-scalar namespaces since all the methods would have to be in one. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php