destructuring: as patterns?

Brendan Eich brendan at mozilla.org
Fri Apr 20 08:12:20 PDT 2012


Andreas Rossberg wrote:
> I disagree. That is a bogus analogy. An object pattern is completely
> different from a 'let'. In particular, the latter binds 'mom', but not
> 'dad' and 'auntie'. The proper equivalence (I wouldn't call it a
> duality)

Right. The duality I've cited is between

   let o = {p: q};

and

   let {p: q} = o;

where q and o change places.

Dave's suggestion of

   let {p as q} = o;

does read better in my subjective opinion, even though it diverges the 
pattern langauge (moreso; already diverged) from the object literal 
language.

>   would be
>
>         let {unidentifiedAdult : mom as dad as auntie} = peopleComstants;
> vs
>         let mom as dad as auntie = peopleComstants.unidentifiedAdult;
>
> You cannot even express it without a compositional 'as'.

Agreed. But is it unthinkable to have 'as' (compositional of course) in 
the pattern language only? I bow to your SuccessorML skills :-).

/be


More information about the es-discuss mailing list