Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60792 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18106 invoked from network); 11 Jun 2012 19:26:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2012 19:26:34 -0000 Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain l-i-e.com designates 67.139.134.202 as permitted sender) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:1784] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/D4-18025-86646DF4 for ; Mon, 11 Jun 2012 15:26:33 -0400 Received: (qmail 1299 invoked by uid 98); 11 Jun 2012 19:28:21 -0000 Received: from localhost by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.05 ( Clear:RC:1(127.0.0.1):. Processed in 0.03701 secs); 11 Jun 2012 19:28:21 -0000 Received: from localhost (HELO www.l-i-e.com) (127.0.0.1) by localhost with SMTP; 11 Jun 2012 19:28:21 -0000 Received: from webmail (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Mon, 11 Jun 2012 14:28:21 -0500 Message-ID: <833ec4f42697843267a741e3f50b0bd0.squirrel@www.l-i-e.com> In-Reply-To: <4FD6436B.1080200@sugarcrm.com> References: <496E551C-85F0-423E-89FA-2C5245808320@easen.co.uk> <4D309A4D.9020904@sugarcrm.com> <4FCD07CA.7030605@easen.co.uk> <131ff485e2f37a4388919f1c61fd4816.squirrel@www.l-i-e.com> <4FD6436B.1080200@sugarcrm.com> Date: Mon, 11 Jun 2012 14:28:21 -0500 To: "internals@lists.php.net" User-Agent: SquirrelMail/1.4.21 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] Support negative indexes for arrays and strings From: ceo@l-i-e.com ("Richard Lynch") On Mon, June 11, 2012 2:13 pm, Stas Malyshev wrote: >> And then one would expect some rather complex logic to compute -N >> for >> $var[-N] > > I don't see much of complex logic here, but $a[2] = 'a' would create a > new array element if it does not exist, while $a[-2] can't. Not a big > issue, but somewhat inconsistent I guess. $n = some_incredibly_long_and_complex_computation(); //and, for real fun, sometimes it returns positive, and sometimes negative. $s = $var[$n]; //a few hundred lines later, buried somewhere else if ($n < 0){ //whatever } else{ //something entirely different } Sooner or later, somebody will do that, and I really don't want to have to un-tangle all that mess to figure out if $n is positive or negative for the sake of saving a few keystrokes... -- brain cancer update: http://richardlynch.blogspot.com/search/label/brain%20tumor Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE