Re: [RFC] Square bracket syntax for array destructuringassignment

From: Date: Fri, 08 Apr 2016 12:36:32 +0000
Subject: Re: [RFC] Square bracket syntax for array destructuringassignment
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-92174@lists.php.net to get a copy of this message
Hi Andrea, On 08/04/16 13:26, Andrea Faulds wrote:
Hi Ivan, Ivan Enderlin wrote:
Thanks a lot for this RFC. Huge +1 from the all Hoa's community and myself. However, did you discuss about […] vs. {…}? Most of the time, arrays or vectors constructing are represented by […] symbols while destructing are represented by {…}. What your point of view or arguments here?
I'm not sure I understand what you mean. In JS, for example, you use {} to create an object or for destructuring assignment for an object. But you don't use {} for other cases. [] is used to create arrays and for destructuring assignment from arrays. The pattern resembles the syntax for constructing what it matches against. In Haskell, (…,…) is used for constructing a tuple and pattern-matching against it. I can't think of a language where {…} is used for destructuring or pattern-matching against something which is not written with {…}. Does that make sense? Yup.


« previous php.internals (#92174) next »