Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32680 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72038 invoked by uid 1010); 6 Oct 2007 18:39:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 72022 invoked from network); 6 Oct 2007 18:39:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Oct 2007 18:39:01 -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 63.240.77.83 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 63.240.77.83 sccrmhc13.comcast.net NetCache Data OnTap 5.x Received: from [63.240.77.83] ([63.240.77.83:58852] helo=sccrmhc13.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/FC-26050-446D7074 for ; Sat, 06 Oct 2007 14:39:01 -0400 Received: from earth.ufp (c-71-228-13-89.hsd1.il.comcast.net[71.228.13.89]) by comcast.net (sccrmhc13) with ESMTP id <2007100618385701300pgp9le>; Sat, 6 Oct 2007 18:38:58 +0000 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id 72AE5D8260 for ; Sat, 6 Oct 2007 13:38:58 -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 u-cT3F+0RpBx for ; Sat, 6 Oct 2007 13:38:58 -0500 (CDT) Received: from vulcan.ufp (vulcan.ufp [192.168.42.4]) by earth.ufp (Postfix) with ESMTP id 4149ED818B for ; Sat, 6 Oct 2007 13:38:47 -0500 (CDT) To: internals@lists.php.net Date: Sat, 6 Oct 2007 13:38:47 -0500 User-Agent: KMail/1.9.6 References: <200710042005.30734.larry@garfieldtech.com> <285930281.20071006200938@marcus-boerger.de> In-Reply-To: <285930281.20071006200938@marcus-boerger.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200710061338.47307.larry@garfieldtech.com> Subject: Re: [PHP-DEV] substr/array_slice in [] From: larry@garfieldtech.com (Larry Garfield) I have no love for Perl (and a rather strong dislike of it), but I have to agree with those who say that "looks like Perl" is a lame reason to reject something. PHP's object system looks an awful lot like Java, too. That doesn't make it bad. "Too unreadable", "not approachable enough", "too inflexible", etc. are perfectly valid reasons to reject a syntax. "Looks like " is not, I content, one of them. On Saturday 06 October 2007, Marcus Boerger wrote: > 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 -- 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