Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85283 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80266 invoked from network); 20 Mar 2015 13:04:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 13:04:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:37025] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/C0-25408-8FA1C055 for ; Fri, 20 Mar 2015 08:04:56 -0500 Received: by wixw10 with SMTP id w10so19927367wix.0 for ; Fri, 20 Mar 2015 06:04:53 -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=avYF1iKE4Un4SiBSpE0botQQgJC8unjy18mUboZg2yY=; b=sDWanzMBUKwCtwngWrARdx+Q7LtH1oIwXPnqFrQFIrm3R12XGRcr/Cj5mPRfekRU0V rvDTVRuvvaeZ3Q5/9K6q1i4RKVlDc7KdZU/PXa3hmOXJzrQ+0EKW7/Bt+5XWz6OsmkNM QlmKpE1irLPYdBWo74HrUP/9kTJp9h31fxAkY+V06ydfuwZHw/p7getj1Uz1SOr1wr0P pn87j/WvU8/vYTKy7ECXeHM8Cm6qFfQM8UPiMG2m+mxrEgt+r3UOnGldGNtJJPoQaMvv vNQ4S9mu9yDcaN3Eq0XF4q/u+zqqENvhI6X1YW4Vez4I2JnHVdazGma49sH2eptxZkCB EMfQ== X-Received: by 10.180.189.35 with SMTP id gf3mr5116186wic.5.1426856693895; Fri, 20 Mar 2015 06:04:53 -0700 (PDT) Received: from [192.168.0.159] ([62.189.198.114]) by mx.google.com with ESMTPSA id yr10sm6320449wjc.0.2015.03.20.06.04.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Mar 2015 06:04:53 -0700 (PDT) Message-ID: <550C1AE4.8090607@gmail.com> Date: Fri, 20 Mar 2015 13:04:36 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Alex Bowers CC: internals@lists.php.net References: <550B5A81.1090706@gmail.com> <550B7189.4040608@gmail.com> <7486C296-7535-4633-AFE2-02E7BBC67BC5@gmail.com> <550C1176.9050307@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC - Array slice syntactic sugar From: rowan.collins@gmail.com (Rowan Collins) Alex Bowers wrote on 20/03/2015 12:32: > We also need to consider then the possibility of setting data by position. > > What should $array[@1:3] = [1,2,3] do? > > Should it overwrite the values there, and append any that don't exist, > or should it be a parse error? > Good catch. I guess it could delete the range and replace with the new value, regardless of size - then you could remove elements from an array with it, too: $array[@1:3] = []; // Remove the second through fourth element $array['x':'z'] = []; // Remove all elements with keys between 'x' and 'z', inclusive Not sure how that compares to other languages with similar syntax. It would be kind of cool if it applied to string subscripts as well: $version = 'PHP 5.6.1'; $version{4:} = '7!'; echo $version; // 'PHP 7!' Regards, -- Rowan Collins [IMSoP]