Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85343 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62754 invoked from network); 20 Mar 2015 22:12:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 22:12:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.179 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.179 mail-pd0-f179.google.com Received: from [209.85.192.179] ([209.85.192.179:34681] helo=mail-pd0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/72-64120-E3B9C055 for ; Fri, 20 Mar 2015 17:12:14 -0500 Received: by pdbni2 with SMTP id ni2so120645350pdb.1 for ; Fri, 20 Mar 2015 15:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=lhFewj1bYunGsmJDMqemrVPTw8opaZay8aQPN4m8rKM=; b=WR7IqiXqwaeKUZWodUmP8bJmE9keZUw66WB0tSqSBTL/K65AtjuNw6mtlGVX99BeKR mLZJqJyWkGF4a2D8e9YZNpoOA4KxcdXv/lEMNHODLFLjooO6zlMO39TTVnxqLzI8wh1q 4qg+BPmMyh5W2eY7C26snnOqUvujR0itkpDWenqYx7lzzS4wJc7qiUqU2rNT7ZSwGkQG mxFU14dVG3Rd5f2U3xqS0rRsSRTtQRvhBD4PEvzpfx2Q5cYeeapXxrCepuVhNcyIP0pp dab56FemYjYDohY7ilj7KEz29exLGCCKll7gzEYJjRMgjrbJb+dO4XhfoLLNDj37TqoF gA6g== X-Received: by 10.70.41.71 with SMTP id d7mr173431051pdl.44.1426889531741; Fri, 20 Mar 2015 15:12:11 -0700 (PDT) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id ra10sm61193pbb.24.2015.03.20.15.12.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Mar 2015 15:12:10 -0700 (PDT) Message-ID: <550C9B39.5080801@gmail.com> Date: Fri, 20 Mar 2015 15:12:09 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Alex Bowers , Christoph Becker CC: PHP Internals References: <550B5A81.1090706@gmail.com> <550C8879.70002@gmail.com> <550C90EF.7080404@gmx.de> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC - Array slice syntactic sugar From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > To be the same, your example would have to be: > > // alternative old > foreach(array_slice($results, 0, 9, true) as $result) { > echo $result . "\n"; // 1 2 3 4 5 6 7 8 9 > } > > since this will preserve the array keys. You're not using the keys in foreach, so why you need to preserve them? > $array[*1:4] = [1,2,3,4]; // Sets array items 1 through 4 to be the > values (and keys if provided), of the array assigned. This may be not so easy to implement - imagine passing $array[*1:4] by reference. You should be able to do so, since $array[*1:4] is an lvalue for you, but what would you pass? What if $array changes in the meantime? There's a big can of worms here. And you already have array_splice which doesn't have these issues. -- Stas Malyshev smalyshev@gmail.com