Looking through the destructuring proposal

   http://wiki.ecmascript.org/doku.php?id=harmony:destructuring

there seems to be no mention of 'as' patterns. In typical pattern
matching constructs (SML, Haskell, ..), 'as' patterns allow to name a sub-object while continuing the match for its sub-structures. For instance, with
   var obj = { a: 0, b: { x: 1, y: 2} };

something like

   let { b: b as {x,y} } = obj

would result in the bindings of b to obj.b, x to obj.b.x, y to obj.b.y.

This avoids needless repetition when both a subobject and its
components need to be extracted. Without 'as', each such case
leads to a separate destructuring assignment

   let { b  } = obj
   let { b: {x,y} } = obj

Shouldn't 'as' patterns be included in destructuring? Or have I
missed an equivalent feature?

Claus

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to