Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85316 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92743 invoked from network); 20 Mar 2015 18:37:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 18:37:19 -0000 Authentication-Results: pb1.pair.com header.from=bowersbros@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bowersbros@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.180 as permitted sender) X-PHP-List-Original-Sender: bowersbros@gmail.com X-Host-Fingerprint: 74.125.82.180 mail-we0-f180.google.com Received: from [74.125.82.180] ([74.125.82.180:36062] helo=mail-we0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/B3-64120-FD76C055 for ; Fri, 20 Mar 2015 13:33:03 -0500 Received: by wetk59 with SMTP id k59so88678590wet.3 for ; Fri, 20 Mar 2015 11:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=TbU2tRxIfnDMIOgjPE0M4+nY4EbEePJlxgYW8N5T+i0=; b=RWBn0a5QbSIBkzLaPvEpT1+psp15XrNCJFh9HrhD2yjHr57eLVpSK2SJMdT8DrYLGn 6GRRJ3tStx4S5Fs+8bg9znQZoxhtehWj+I3U62t746OwS8Wi1BWTkuqTlGHWjcasd50T mINMEmUiPA6esNgeN448rfoFFEryB7Uf3B2cXXo9E87J7NPcN6+vtcSKKidX1oji7xfP zHON8BTBm3GFnCcvNyh0Sl1p7aPkkhDaqJsJpA1CQYOppLcSIXp339rc3VHeZpAy8nHe N0wEFMXRTNROLIeAv9QfSHxXVGtQ/lRyWn607lUTIzriL5vpUaqtg3AuS/g0sz+24RP7 Sw3Q== MIME-Version: 1.0 X-Received: by 10.194.6.228 with SMTP id e4mr161047418wja.63.1426876379836; Fri, 20 Mar 2015 11:32:59 -0700 (PDT) Received: by 10.28.62.84 with HTTP; Fri, 20 Mar 2015 11:32:59 -0700 (PDT) In-Reply-To: <550C6422.6080009@gmail.com> References: <550B5A81.1090706@gmail.com> <550B7189.4040608@gmail.com> <7486C296-7535-4633-AFE2-02E7BBC67BC5@gmail.com> <550C1176.9050307@gmail.com> <550C1AE4.8090607@gmail.com> <550C1EC3.8000106@gmail.com> <550C317E.8020508@gmail.com> <550C6422.6080009@gmail.com> Date: Fri, 20 Mar 2015 18:32:59 +0000 Message-ID: To: Rowan Collins Cc: Leigh , internals@lists.php.net Content-Type: multipart/alternative; boundary=047d7b5d86adc237690511bc8b98 Subject: Re: [PHP-DEV] RFC - Array slice syntactic sugar From: bowersbros@gmail.com (Alex Bowers) --047d7b5d86adc237690511bc8b98 Content-Type: text/plain; charset=UTF-8 > > That's why I propose a new syntax such as $thing[@0], $thing[@-1] I have to agree that a new syntax will be required by this. On 20 March 2015 at 18:17, Rowan Collins wrote: > Leigh wrote on 20/03/2015 16:17: > >> >> For $thing[-1] I think this only works for strings (and I have this >> implemented, should probably RFC it) https://github.com/lt/php-src/ >> tree/string_negative_offset >> >> $thing[-1:] is in scope for arrays though >> >> > Why? Getting the last value of an array is just as useful as getting the > last character of a string. > > It doesn't work *with that syntax*, because -1 is a valid key, just as > $thing[0] can't mean "first value of array" because it already means "value > with key 0". That's why I propose a new syntax such as $thing[@0], > $thing[@-1], etc. > > Regards, > -- > Rowan Collins > [IMSoP] > --047d7b5d86adc237690511bc8b98--