Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53419 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8825 invoked from network); 20 Jun 2011 15:49:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 15:49:18 -0000 Authentication-Results: pb1.pair.com header.from=robert@xarg.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=robert@xarg.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain xarg.org from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: robert@xarg.org X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:59725] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/A7-34681-DFB6FFD4 for ; Mon, 20 Jun 2011 11:49:17 -0400 Received: by vwl1 with SMTP id 1so1267303vwl.29 for ; Mon, 20 Jun 2011 08:49:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.185.105 with SMTP id fb9mr4667565vdc.286.1308584954963; Mon, 20 Jun 2011 08:49:14 -0700 (PDT) Received: by 10.220.45.196 with HTTP; Mon, 20 Jun 2011 08:49:14 -0700 (PDT) X-Originating-IP: [92.225.216.141] In-Reply-To: <1308584208.6296.9.camel@guybrush> References: <1308584208.6296.9.camel@guybrush> Date: Mon, 20 Jun 2011 17:49:14 +0200 Message-ID: To: =?ISO-8859-1?Q?Johannes_Schl=FCter?= Cc: Etienne Kneuss , Derick Rethans , internals@lists.php.net Content-Type: multipart/alternative; boundary=bcaec547ca756626f404a626ad6b Subject: Re: [PHP-DEV] Negative string offsets From: robert@xarg.org (Robert Eisele) --bcaec547ca756626f404a626ad6b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I would not consider this for arrays and objects, too. If we had real arrays, this would make sense but they are HT's and therewith it can also b= e explained that -1 is an element and not the end of the chained list behind the HT. 2011/6/20 Johannes Schl=FCter > On Mon, 2011-06-20 at 16:31 +0200, Etienne Kneuss wrote: > > >> Negative string offsets is a wish and also an implementation of my > running > > >> PHP version for long. It operates in the same fashion like substr() > with > > >> negative offsets, but avoids the function call and is much smarter i= f > one > > >> single character has to be extracted: > > > Do you mean ArrayObject? ArrayAccess is the interface. > > Regardless, I don't believe it makes sense to change the semantics of > > those indexes for arrays, since arrays can define negative indexes. > > i.e. $a =3D array(-1 =3D> "foo", 2 =3D> "bar"); $a[-1] should really be > > "foo", and not "bar". > > This clearly shows the inconsistency this brings. Maybe $var{$offset} > should be clearly deprecated for arrays and $var[$offset] for strings as > in PHP they work differently. > > johannes > > > --bcaec547ca756626f404a626ad6b--