Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32676 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61325 invoked by uid 1010); 6 Oct 2007 18:09:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61309 invoked from network); 6 Oct 2007 18:09:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Oct 2007 18:09:46 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:54616] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/1B-26050-96FC7074 for ; Sat, 06 Oct 2007 14:09:45 -0400 Received: from MBOERGER-ZRH (unknown [216.239.45.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 3AD211B3668; Sat, 6 Oct 2007 20:09:42 +0200 (CEST) Date: Sat, 6 Oct 2007 20:09:38 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <285930281.20071006200938@marcus-boerger.de> To: Larry Garfield CC: internals@lists.php.net In-Reply-To: <200710042005.30734.larry@garfieldtech.com> References: <52dbac0f0710011236u626c9566l6ab474dce0b3132e@mail.gmail.com> <200710042005.30734.larry@garfieldtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] substr/array_slice in [] From: helly@php.net (Marcus Boerger) Hello Larry, ArrayAccess is not designed to work in any array functions and we explicitly decided against going that route. We wanted ArrayAccess to support the array syntax, so [x,y] should be supported if we want that. However I agree that this kind of slicing is a bit too perlish or pythonish. marcus Friday, October 5, 2007, 3:05:30 AM, you 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. 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 Best regards, Marcus