On a somewhat related note (and going back a little to my original patch), languages like python and ruby allow slicing on array/string objects with $string_or_array[start:end] syntax. I think this would be really useful syntax in PHP as well (and would of course make the initial patch I submitted obsolete). The one thing I was hesitant about with my patch was polluting the global function space for PHP, and I think adding new and specific syntax to provide these things is much better.
I have no idea how feasible it is given PHP's internal structure, but if it was possible I would be glad to try to write a patch for it. -Dan On Thu, Mar 31, 2011 at 11:10 AM, Rasmus Lerdorf <ras...@lerdorf.com> wrote: > On 03/31/2011 10:58 AM, Martin Scotta wrote: > > I think it's time to stop thinking in terms of "functions" and move > > forward to "abstractions" > > > > $s1 = 'string'; > > $s1->contains($s2); > > > > $s1->indexOf($s2) === strpos($s1, $s2); > > > > Why can't the strings be exposed as pseudo-objects ? users can choose to > > use them as a regular strings or by calling methods on it. > > This is actually something I have been toying with a bit. Adding the > ability to call methods on both strings and arrays. I still don't like > the idea of making them real objects as the overhead and the amount of > code that would need to be changed in the core and in every extension is > daunting. Anybody out there have a patch along these lines? > > -Rasmus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >