Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85310 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72166 invoked from network); 20 Mar 2015 17:23:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2015 17:23:22 -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.175 as permitted sender) X-PHP-List-Original-Sender: bowersbros@gmail.com X-Host-Fingerprint: 74.125.82.175 mail-we0-f175.google.com Received: from [74.125.82.175] ([74.125.82.175:36615] helo=mail-we0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3F/80-64120-CB65C055 for ; Fri, 20 Mar 2015 12:19:56 -0500 Received: by wetk59 with SMTP id k59so87246728wet.3 for ; Fri, 20 Mar 2015 10:19:52 -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=DkWkrvtNhV5NBHqrN9zS5YljrfntJI2own2MwWTPbNA=; b=aSM3aS9tEySPGE3/gtOYie6LgQ3HDaxBNxB2yTs1CrFR5FYrDxCxIg3RZt8MSlQGS3 18TlZ+OeAjTQB1FA4tN3NzUBkoe25mOZo6CyiUCD9YeKzcLnQOqF1M8iiN6es32hmJoA yd3zA8SoHRDMK0vnz+86TxBndGzfqDPYeZzm0man8U5MP5W66gIaC/RL3HOW5dHMXTLA i284IMTGo3zZ3PjhjbZ7ubrXLd8pD6o0en27Up/pW61+9sqIYIksSs68kBesHstXFBwx JiWSkVmkyBbeizi431rAXsZ6WbfkGBLA3o7G0AoymqiGG4T4WR6HfhWt+K6fpup9ySxo qSzg== MIME-Version: 1.0 X-Received: by 10.194.179.41 with SMTP id dd9mr165667731wjc.72.1426871992721; Fri, 20 Mar 2015 10:19:52 -0700 (PDT) Received: by 10.28.62.84 with HTTP; Fri, 20 Mar 2015 10:19:51 -0700 (PDT) Received: by 10.28.62.84 with HTTP; Fri, 20 Mar 2015 10:19:51 -0700 (PDT) In-Reply-To: <114590901.20150320170242@yahoo.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> <550C1DEC.5060706@gmail.com> <15030741.20150320143622@yahoo.com> <114590901.20150320170242@yahoo.com> Date: Fri, 20 Mar 2015 17:19:51 +0000 Message-ID: To: Vik Hudec Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=089e01493d5c4427430511bb86b9 Subject: Re: [PHP-DEV] RFC - Array slice syntactic sugar From: bowersbros@gmail.com (Alex Bowers) --089e01493d5c4427430511bb86b9 Content-Type: text/plain; charset=UTF-8 When you say restrict to one each. Do you mean one for strings and one for arrays? If so I'd have to disagree with this, since having the same operation available to both is less likely to give mistakes. Can you give an example of an actual benefit for this? Since this would cause a backwards incompatible change. I can't imagine many places if any use the curly brackets for arrays or strings, but since it exists there may be people using it. Changing the behaviour of this to only work for one of the two options seems unnecessary in the name of making code slightly more apparent on initial reading. But variable names and so on should be used to help distinguish from array or strings anyway. On 20 Mar 2015 17:02, "Vik Hudec" wrote: > Hi Alex, > > On Fri, 2015-03-20, at 14:52, Alex Bowers wrote: > > > But I don't think we should only match {} for strings and [] for arrays, > > that seems broken to me. > > > Maybe you misunderstand me, I am against using two syntaxes for different > > things. > > Based on your reply; yes, I'm definitely misunderstanding! In summary, we > already have two different operations: > > (1) Accessing an array's element using subscript notation, eg: > $foo = array('bar'); var_dump($foo[0]); // string(3) "bar" > > (2) Accessing a string's character using subscript notation, eg: > $foo = 'bar'; var_dump($foo[0]); // string(1) "b" > > And we already have two different syntaxes: $var[$offset] and > $var{$offset}. > > So we have two syntaxes that each perform two operations. Are we in > agreement that this isn't a good thing? > > Sorry that this is all a little off-topic, but I'm interested in people's > opinions because I'm considering a future RFC. My proposition would be to > restrict the two subscript syntaxes to one operation each. And if your > slice > sugar RFC aims to augment the functionality of either one or both of these > syntaxes, then that's relevant to me. > > Vik > > --089e01493d5c4427430511bb86b9--