Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62613 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47351 invoked from network); 31 Aug 2012 17:11:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Aug 2012 17:11:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:46150] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/F1-37167-820F0405 for ; Fri, 31 Aug 2012 13:11:06 -0400 Received: by vbbfs19 with SMTP id fs19so3671880vbb.29 for ; Fri, 31 Aug 2012 10:11:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding:x-gm-message-state; bh=nBOukbkpcmv55V3Y9+7Qh8fptfMlpe3jt8CWpfllcz4=; b=jzXRL99o/sRaF4XhbvGQj2qHoegGaNaXmCqxr6s6kcFU/ud4IS6FnAepXSyQH0XB1T fSUSH9psEBz5peA7OLl9K5HbejVanrLhCbfRyiqfRD8PGOKXeERvR+qe0fqmuk0sial7 xCR+i9W37d00I+o/miMV5qaf3WHpc3To5bEIkqTy55sqW2oUdYZBdMdqUGoKI7pHu5bU bTAoN4Tp9b38AxLKFnz59rU8uCCerL+g99BGFDA4cMbwYbnXCLlRTL2mnXt4ym6xBlxA d9lSCJPBKLCsS/evn2sP3ajqZRjpIXlC0Zk3m3BRhY0Ly6XaLg/u2o4a76YzflUivjDv YTzQ== MIME-Version: 1.0 Received: by 10.221.10.13 with SMTP id oy13mr6402464vcb.14.1346433061551; Fri, 31 Aug 2012 10:11:01 -0700 (PDT) Received: by 10.58.91.162 with HTTP; Fri, 31 Aug 2012 10:11:01 -0700 (PDT) In-Reply-To: References: Date: Fri, 31 Aug 2012 13:11:01 -0400 Message-ID: To: Ferenc Kovacs Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlwjZ+nYVV5zT56w9/VR2boJI5wDx9vjm39m7SMisiRySht98kHGNaKKR0vI06096rs4WGu Subject: Re: [PHP-DEV] Support negative indexes for arrays and strings From: rasmus@mindplay.dk (Rasmus Schultz) Yes, typo! sorry. $array =3D array(1001, 1002, 1003, 1004); $number =3D $array[-1]; // =3D> 1004 $array[-1] =3D 1005; $number =3D $array[-1]; // =3D> ???? Looking at the resulting code, I would like to point out also that it's extremely misleading... because $array[-1] references two completely different elements depending on whether you're reading or writing the value... unless $array[-1] =3D 1005 would actually overwrite the last element in the array - in which case it gets even more dangerous, as well as breaking backwards compatibility... On Fri, Aug 31, 2012 at 9:24 AM, Ferenc Kovacs wrote: > > > On Fri, Aug 31, 2012 at 3:14 PM, Rasmus Schultz wrot= e: >> >> Having thought about this for a while, I think this is a bad idea - here= 's >> why: >> >> $array =3D array(1001, 1002, 1003, 1004); >> >> $number =3D $array[-1]; // =3D> 1004 >> >> $number[-1] =3D 1005; >> >> $number =3D $array[-1]; // =3D> ???? >> >> Obviously, the last statement must return 1005, since otherwise that >> value would be inaccessible. >> > > maybe you wanted to write > $array[-1] =3D 1005; > instead of > $number[-1] =3D 1005; > ? > > otherwise I can't see the problem that you are mentioning. > could you clarify? > > -- > Ferenc Kov=E1cs > @Tyr43l - http://tyrael.hu