Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85285 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84634 invoked from network); 20 Mar 2015 13:10:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 13:10:15 -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 209.85.212.175 as permitted sender) X-PHP-List-Original-Sender: bowersbros@gmail.com X-Host-Fingerprint: 209.85.212.175 mail-wi0-f175.google.com Received: from [209.85.212.175] ([209.85.212.175:35709] helo=mail-wi0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/C1-25408-63C1C055 for ; Fri, 20 Mar 2015 08:10:14 -0500 Received: by wibdy8 with SMTP id dy8so16682877wib.0 for ; Fri, 20 Mar 2015 06:10:11 -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=wHRPmUDGZUjUReIWa4enQJx4JmKw4n51tJ+MkVCW2Ys=; b=IufmhBJBGms8yWK2vzpAQRxlmyy1t11eAzF+XMy5kqsZfcCCwoDopwwRhUWqqBRL05 6UoQevpwPc96aj9eu66cyOwFRgzdxjO168iDNlwgSnefk5iOAh6D6a1UlpwTPkVfLvoP +IWiP6AMWGJ+pA+HIikjRSNB4lMj7dkRmTqu9CgUSuq+uk5W3GXjD61SUVgOtNoGwPD3 SK/9dLi+c39nE0ZgN/9YXNSmHaG9RfwtJkKc/dsKcO5rQaULiNsj+KbkSRZhgoVz68zT VRwoCJ7mgJvkg+HZZly1XP9By5iWwyhl55GR9qjqc5inmv6W5FIWP+ipyj5Deo3GX9lY munA== MIME-Version: 1.0 X-Received: by 10.194.179.41 with SMTP id dd9mr163879024wjc.72.1426857011492; Fri, 20 Mar 2015 06:10:11 -0700 (PDT) Received: by 10.28.62.84 with HTTP; Fri, 20 Mar 2015 06:10:11 -0700 (PDT) In-Reply-To: <550C1AE4.8090607@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> Date: Fri, 20 Mar 2015 13:10:11 +0000 Message-ID: To: Rowan Collins Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=089e01493d5c50c4950511b80992 Subject: Re: [PHP-DEV] RFC - Array slice syntactic sugar From: bowersbros@gmail.com (Alex Bowers) --089e01493d5c50c4950511b80992 Content-Type: text/plain; charset=UTF-8 > > $array['x':'z'] = []; // Remove all elements with keys between 'x' and > 'z', inclusive I believe i mentioned in the past about strings not being allowed for ranges, since there is no real way to check this (and this appears to be by key not by index) which should be a separate RFC thread, assuming this one gets accepted to be expanded upon. On 20 March 2015 at 13:04, Rowan Collins wrote: > 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] > --089e01493d5c50c4950511b80992--