Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62706 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5103 invoked from network); 3 Sep 2012 07:37:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2012 07:37:47 -0000 Authentication-Results: pb1.pair.com header.from=hello@apfelbox.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=hello@apfelbox.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain apfelbox.net from 83.169.28.40 cause and error) X-PHP-List-Original-Sender: hello@apfelbox.net X-Host-Fingerprint: 83.169.28.40 vwp5063.webpack.hosteurope.de Received: from [83.169.28.40] ([83.169.28.40:55417] helo=vwp5063.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/12-25891-94E54405 for ; Mon, 03 Sep 2012 03:37:46 -0400 Received: from hsi-kbw-46-223-104-182.hsi.kabel-badenwuerttemberg.de ([46.223.104.182] helo=[192.168.0.75]); authenticated by vwp5063.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1T8RE5-00034v-LA; Mon, 03 Sep 2012 09:37:41 +0200 Date: Mon, 3 Sep 2012 09:37:41 +0200 To: slevy1@pipeline.com Cc: internals@lists.php.net Message-ID: <96E453F9E8B844E090D9D375033A9E53@apfelbox.net> In-Reply-To: <13095916.1346546580825.JavaMail.root@wamui-haziran.atl.sa.earthlink.net> References: <13095916.1346546580825.JavaMail.root@wamui-haziran.atl.sa.earthlink.net> X-Mailer: sparrow 1.6.3 (build 1172) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="50445e45_6de91b18_95" X-bounce-key: webpack.hosteurope.de;hello@apfelbox.net;1346657866;6a63cfbc; Subject: Re: [PHP-DEV] Re: Support negative indexes for arrays and strings From: hello@apfelbox.net (Jannik Zschiesche) --50445e45_6de91b18_95 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Am Sonntag, 2. September 2012 um 02:43 schrieb slevy1@pipeline.com: > The idea was originally proposed by Marc Easen who created a patch and asked for help with putting together an RFC. I have yet to see a formal proposal but on the list Easen modified his idea so that it should apply to strings alone. With that in mind, would it really cause problems to have code like this: > > $string = "Roses are red"; > $string[-3] = "R"; // modifying $string[10] > echo $string; // Roses are Red > > The negative indexing provides a pleasurable way to easily access part of a string; it's simple and should be fast, too. > > I think Easen's proposal is laudatory and I for one would like to see it happen for PHP and provide users with more ease and satisfaction in working with the language. > > SL Hi, as I understood, a lot of people seem to have problems with this proposal, since arrays and strings could (and maybe should) behave the same. The main problem arises from the ambiguity for $array[-1] for arrays. But this is easily solvable: just introduce a slice operator. $array[:-1] and the ambiguity is gone. -- Cheers Jannik Zschiesche --50445e45_6de91b18_95--