Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53452 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9775 invoked from network); 20 Jun 2011 21:36:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 21:36:16 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 config.schlueters.de Received: from [217.114.211.66] ([217.114.211.66:41837] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/E3-22948-F4DBFFD4 for ; Mon, 20 Jun 2011 17:36:15 -0400 Received: from ka.local (ka.local [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPS id 9577C74582; Mon, 20 Jun 2011 23:36:12 +0200 (CEST) Received: (from webservd@localhost) by ka.local (8.14.4+Sun/8.14.4/Submit) id p5KLaCv5000176; Mon, 20 Jun 2011 23:36:12 +0200 (CEST) X-Authentication-Warning: ka.local: webservd set sender to johannes@schlueters.de using -f To: Robert Eisele MIME-Version: 1.0 Date: Mon, 20 Jun 2011 23:36:12 +0200 Cc: Etienne Kneuss , Derick Rethans , In-Reply-To: References: <1308584208.6296.9.camel@guybrush> <1308586150.6296.13.camel@guybrush> Message-ID: <3fb7d815f988b4368bbb814d97e650d6@localhost> X-Sender: johannes@schlueters.de User-Agent: RoundCube Webmail/0.3.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Negative string offsets From: johannes@schlueters.de (=?UTF-8?Q?Johannes_Schl=C3=BCter?=) On Mon, 20 Jun 2011 18:27:48 +0200, Robert Eisele wrote: > 2011/6/20 Johannes Schlüter >> Yes. So having this in the current form accepted means that >> >> $a[-1]; >> >> can have two meanings: >> >> 1) Get the last item (byte in a string) >> 2) Get item `-1` (in an array) >> > > Yes, sure. But if this feature is documented well, I can't see any > problems with this, especially if the trend goes towards a more > typed language where the user knows about the used data-type. I consider having exact same semantics for two quite different operations bad. And I don't buy the "more typed language" argument. What does echo my_cool_function()[-1]; do? >> Which are to different things. >> >> Currently we treat >> >> $a{$o} and $a[$o] >> >> as equal. My suggestion was to split this up to avoid the conflict from >> above. I didn't suggest adding support for $a[-1] as last element for >> arrays, I know quite well why this won't make sense. >> > > I know about the equality of the two bracket forms. But I read somewhere > that > the trend goes towards [] - and maybe it was something from you. There's no clear trend on this. It's a back and forth. Always depends on the features we think about. johannes