Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32645 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70654 invoked by uid 1010); 5 Oct 2007 07:52:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 70639 invoked from network); 5 Oct 2007 07:52:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Oct 2007 07:52:31 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.94.239.5 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.94.239.5 jdi.jdi-ict.nl Linux 2.6 Received: from [82.94.239.5] ([82.94.239.5:50457] helo=jdi.jdi-ict.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/E6-25026-D3DE5074 for ; Fri, 05 Oct 2007 03:52:30 -0400 Received: from localhost (localhost [127.0.0.1]) by jdi.jdi-ict.nl (8.13.7/8.12.11) with ESMTP id l957qDSt014694; Fri, 5 Oct 2007 09:52:14 +0200 Date: Fri, 5 Oct 2007 09:52:13 +0200 (CEST) X-X-Sender: derick@kossu.ez.no To: Larry Garfield cc: PHP Developers Mailing List In-Reply-To: <200710042005.30734.larry@garfieldtech.com> Message-ID: References: <52dbac0f0710011236u626c9566l6ab474dce0b3132e@mail.gmail.com> <200710042005.30734.larry@garfieldtech.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Subject: Re: [PHP-DEV] substr/array_slice in [] From: derick@php.net (Derick Rethans) On Thu, 4 Oct 2007, Larry Garfield wrote: > On Tuesday 02 October 2007, Alexey Zakhlestin wrote: > > On 10/1/07, Martin Alterisio 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