fail-fast object destructuring

Russell Leggett russell.leggett at gmail.com
Wed Jul 11 08:35:25 PDT 2012


On Wed, Jul 11, 2012 at 11:31 AM, Andreas Rossberg <rossberg at google.com>wrote:

> On 11 July 2012 17:20, Russell Leggett <russell.leggett at gmail.com> wrote:
>
>> On Wed, Jul 11, 2012 at 7:14 AM, Andreas Rossberg <rossberg at google.com>wrote:
>>
>>> AFAICS, '?' on a variable itself would always be redundant, because a
>>> variable pattern is irrefutable anyway.
>>>
>>
>> So you're saying that even this should match in a refutable pattern:
>>
>>    let [a,b,c] = [1,2];
>>
>> I would expect that to fail, especially in a hypothetical pattern
>> matching construct.
>>
>
> That would fail because the array pattern is refutable. What I meant is
> something else, namely that there is no difference between these:
>
>   let x = ...
>   let ?x = ...
>
> or these:
>
>   let {x: x, y: y} = ...
>   let {x: ?x, y: ?y} = ...
>
> Pattern matching recursively decomposes the RHS and matches a (sub)value
> against the respective (sub)pattern of the LHS. Once you reach a variable,
> that submatch is unconditional, so a '?' doesn't change anything.
>

I see. Yes, I would be happy to get rid of any of those useless patterns.

- Russ


>
> /Andreas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120711/f4e582d3/attachment.html>


More information about the es-discuss mailing list