fail-fast object destructuring

Russell Leggett russell.leggett at gmail.com
Wed Jul 11 10:21:25 PDT 2012


On Wed, Jul 11, 2012 at 1:06 PM, Brendan Eich <brendan at mozilla.org> wrote:

> Russell Leggett wrote:
>
>>
>>
>>
>>     Russell asked about 'length' -- per a previous thread, I thought
>>     we agreed that one [[Get]] of 'length' would be done before
>>     matching if and only if the array literal contains a spread
>>     (covering rest, the dual for a pattern of spread in the array
>>     literal corresponding to the pattern).
>>
>>
>> Yes, I saw this in the proposal algorithm. The reason I ask is because it
>> seems odd to have an additional structural requirement in some cases but
>> not others. Of course, I understand why, but it sort of makes it look like
>> [] implies additional array-like structure in one case, but not in another.
>>
>
> You get what you ask for. Pay as you go. Buy by the yard.
>
> Ok, out of clichés but I hope we aren't going to revisit and impose a
> mandatory [[Get]] of 'length' on all array destructuring forms. That is
> otiose and costly (potentially very).
>
> The presence of ...rest is static syntax, so there's no runtime
> maybe/maybe-not hazard.


It would not have to be a [[Get]] of 'length', just a check for its
existence. Its no deal breaker for me, but it seemed a little inconsistent.
We could also be more strict with an Array.isArray check, but that seems
too strict. Anyway, just a thought.

- Russ


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


More information about the es-discuss mailing list