Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85333 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29532 invoked from network); 20 Mar 2015 21:13:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 21:13:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=bowersbros@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bowersbros@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: bowersbros@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:36708] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/4B-64120-19D8C055 for ; Fri, 20 Mar 2015 16:13:53 -0500 Received: by wetk59 with SMTP id k59so91409058wet.3 for ; Fri, 20 Mar 2015 14:13:50 -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=FlFZMKYyMqG2b+9WTbSxluOkeedYnQfrT4uwouM/Y7Y=; b=uSE9KIQ1pzRasHONSTIum3YM0Sf00J5AxMkRLOvS0kr07VZmbPgskqMFWGtBoraVT7 zLdRX7HZd4Bs4X4YTLuze0sq+l6Kjsr1i+1jh0MucE84Wr8Mbnfjwy/1WA6aG4J9c5/k 9RteK22A2x4Auk3VTaBd4vYA8skGH795liMuyKjguBh5V6yyJPc5muYiiC9RfvvLcAJ4 bjYrYdumnQwxnUOI4BQRATg+hyJnMTYKHosAzrOvY8UlN3VhdfOpe+HoyOZYTHW9Huws pvwVKQ0hQ1j/9eZcl53ldwogJCbrl4t4BkjwxtEIt5ulfG7KrHv8iWpMBsHfrquLteOA /Wvw== MIME-Version: 1.0 X-Received: by 10.194.6.228 with SMTP id e4mr161964399wja.63.1426886030336; Fri, 20 Mar 2015 14:13:50 -0700 (PDT) Received: by 10.28.62.84 with HTTP; Fri, 20 Mar 2015 14:13:50 -0700 (PDT) In-Reply-To: <550C8879.70002@gmail.com> References: <550B5A81.1090706@gmail.com> <550C8879.70002@gmail.com> Date: Fri, 20 Mar 2015 21:13:50 +0000 Message-ID: To: Stanislav Malyshev Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7b5d86adf92d0a0511becacb Subject: Re: [PHP-DEV] RFC - Array slice syntactic sugar From: bowersbros@gmail.com (Alex Bowers) --047d7b5d86adf92d0a0511becacb Content-Type: text/plain; charset=UTF-8 On 20 March 2015 at 20:52, Stanislav Malyshev wrote: > I'm not sure how such operation would be useful, and it definitely would > not be intuitive, as $array[0] and $array[0:1] (assuming non-inclusive > semantic, or [0:0] with inclusive semantics) would return completely > different things. That would happen even if the array has only numeric > keys! This is the main problem with this syntax - unlike most languages > where it is used, PHP arrays are not vectors, they are ordered hashmaps. > Sometimes this is very convenient, sometimes - like for this syntax - it > is not. I think this is the major reason why such proposals failed in > the past. > It would give different results, for a reason. There is currently no way to get an array item by positional index, whilst preserving the keys. This RFC will allow that, with the inclusion of the symbol that will be required for this RFC (slicing by key can be a separate RFC; and is not covered by this RFC). So, if i want to get the items from position 1 through 5, I can use [*1:5] and I will get an array of the items in position 1,2,3,4 and 5; regardless of their keys, as an array. --047d7b5d86adf92d0a0511becacb--