Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62659 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34603 invoked from network); 2 Sep 2012 08:26:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 08:26:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 213.123.20.125 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 213.123.20.125 c2bthomr07.btconnect.com Received: from [213.123.20.125] ([213.123.20.125:40105] helo=mail.btconnect.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/E3-17065-A3813405 for ; Sun, 02 Sep 2012 04:26:36 -0400 Received: from host81-138-11-136.in-addr.btopenworld.com (EHLO _10.0.0.5_) ([81.138.11.136]) by c2bthomr07.btconnect.com with ESMTP id JAW40117; Sun, 02 Sep 2012 09:26:31 +0100 (BST) Message-ID: <50431837.7060106@lsces.co.uk> Date: Sun, 02 Sep 2012 09:26:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120604 Firefox/13.0 SeaMonkey/2.10 MIME-Version: 1.0 To: "internals@lists.php.net" References: <13095916.1346546580825.JavaMail.root@wamui-haziran.atl.sa.earthlink.net> <5042B7F5.7030409@sugarcrm.com> In-Reply-To: <5042B7F5.7030409@sugarcrm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0302.50431837.005C, actions=TAG X-Junkmail-Premium-Raw: score=7/50, refid=2.7.2:2012.9.2.80322:17:7.944, ip=81.138.11.136, rules=__MOZILLA_MSGID, __HAS_MSGID, __SANE_MSGID, __FW_1LN_BOT_MSGID, __HAS_FROM, __USER_AGENT, __MIME_VERSION, __TO_MALFORMED_2, __TO_NO_NAME, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __CT, __CT_TEXT_PLAIN, __CTE, __ANY_URI, __URI_NO_MAILTO, __URI_NO_WWW, __CP_URI_IN_BODY, BODY_ENDS_IN_URL, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS X-Junkmail-Status: score=10/50, host=c2bthomr07.btconnect.com X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0201.50431837.0134:SCFSTAT14830815,ss=1,re=-4.000,fgs=0, ip=0.0.0.0, so=2011-07-25 19:15:43, dmn=2011-05-27 18:58:46, mode=multiengine X-Junkmail-IWF: false Subject: Re: [PHP-DEV] Re: Support negative indexes for arrays and strings From: lester@lsces.co.uk (Lester Caine) Stas Malyshev wrote: >> >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 > I see how this may work for strings and simple vectors, but what about this: > > $a = array(-1 => "foo", -2 => "bar"); echo $a[-1]; > > It should keep returning "foo", right? So then the question is - what > $array[-1] actually means? Right now I'm not sure I understand it. I > guess if somebody wrote an RFC on that it'd make understanding it > easier. I see that the patch seems to address just the string part - but > the subject also mentions arrays. I think making it clear would be helpful. Stanislav I though that the discussion on adding this type of functionality to strings was already a done deal? Despite the obvious problems it introduces. If it's not a done deal, then while I can understand why people thing they like the idea, the clash with other uses of what looks like identical functionality are good enough reason not to carry it forward. I've already pointed out why there is no way that this can be discussed in connection with 'collection arrays' and so there does need to be a clean break between the two for ANY discussion. I believe that PHP is the only language that allows us to use -ve indices ( i.e. keys ) in arrays? That was one of the nice things about PHP when I moved over to it from C and pascal. Introducing two different styles of working with 'indices' even though they apply to different types of object does now seem to be adding to the difficult of educating new users as to why PHP arrays are NOT the same as other array types they may have used? -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk