Re: substr/array_slice in []
| From: | Derick Rethans | Date: | Fri, 05 Oct 2007 07:52:13 +0000 |
| Subject: | Re: substr/array_slice in [] | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32645@lists.php.net to get a copy of this message | ||
On Thu, 4 Oct 2007, Larry Garfield wrote:
> On Tuesday 02 October 2007, Alexey Zakhlestin wrote:
> > On 10/1/07, Martin Alterisio <malterisio777@gmail.com> wrote:
> > > Sorry to bother, I have a few questions on this matter.
> > > How will this impact on the SPL ArrayAccess and related interfaces and
> > > objects?
> > > Will there be an interface to this functionality?
> > > If so, how will ranges be passed through to this interface?
> > > Will this be consistent with substr() and array_slice() if used with an
> > > ArrayAccess implementation?
> >
> > I guess it can be made to work with current ArrayAccess, but result
> > will be quite slow. (it will need to query requested elements
> > one-by-one and recombine those in array)
> >
> > But adding another interface can solve the problem. Ranges can be
> > passed exactly the way they are passed to [] operator
> >
> > public function rangeGet($start, $length);
> > public function rangeSet($start, $length, array $data);
>
> Here's the question I see. Right now, does an ArrayAccess object work with
> array_slice()? If so, then [2, 5] syntax would be just some nice syntactic
> sugar.
It doesn't matter if it works with array_slice() or not. [x] works with
ArrayAccess, so you'd expect [x,y] to work as well otherwise it's
inconsistent.
Derick
--
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org