Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32637 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64644 invoked by uid 1010); 5 Oct 2007 01:05:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 64629 invoked from network); 5 Oct 2007 01:05:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Oct 2007 01:05:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 204.127.225.93 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 204.127.225.93 alnrmhc13.comcast.net NetCache Data OnTap 5.x Received: from [204.127.225.93] ([204.127.225.93:35732] helo=alnrmhc13.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/37-19644-EED85074 for ; Thu, 04 Oct 2007 21:05:52 -0400 Received: from earth.ufp (c-71-228-13-89.hsd1.il.comcast.net[71.228.13.89]) by comcast.net (alnrmhc13) with ESMTP id <20071005010542b13000i78ee>; Fri, 5 Oct 2007 01:05:47 +0000 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id 2354DD8264 for ; Thu, 4 Oct 2007 20:05:43 -0500 (CDT) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ekBDRHytGLWo for ; Thu, 4 Oct 2007 20:05:42 -0500 (CDT) Received: from vulcan.ufp (vulcan.ufp [192.168.42.4]) by earth.ufp (Postfix) with ESMTP id 4B96CD7C6B for ; Thu, 4 Oct 2007 20:05:32 -0500 (CDT) To: internals@lists.php.net Date: Thu, 4 Oct 2007 20:05:30 -0500 User-Agent: KMail/1.9.6 References: <52dbac0f0710011236u626c9566l6ab474dce0b3132e@mail.gmail.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200710042005.30734.larry@garfieldtech.com> Subject: Re: [PHP-DEV] substr/array_slice in [] From: larry@garfieldtech.com (Larry Garfield) 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. If not, then it becomes a powerful new feature, and implementing it on normal arrays and strings becomes just a matter of consistent syntax. Personaly I kinda like it, but I know I'm not the one coding it. :-) -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson