Le 04/08/2012 16:19, Brendan Eich a écrit :
David Bruant wrote:
var context = document.getElementsByTagName('canvas')[0].getContext('2d');

// bikeshed syntax for binding destructuring, my point isn't about syntax here var #{beginPath: begin, moveTo, lineTo, stroke, closePath: end} = context;
    // extracted methods are bound to the context object.


The # was somewhat wanted for records, tuples, and const functions, once.
Ok. As I try to highlight each time I talk about syntax, I'm usually more interested in having a new syntax for something than in the exact syntax. Syntax and ES grammar really are not my specialty. When I propose something I make sure it's a syntax error in current engines, but that's as far as I go. So really, the exact syntax proposal can be thrown away if there are better ideas or if it conflicts with something else.

For DRY, new syntax seems required. From

http://wiki.ecmascript.org/doku.php?id=strawman:bind_operator
The idea of combining the bind operator and bound destructuring is a good one in my opinion.

Your wish to mix auto-bound and unbound method destructuring could be met by:

    var {unbound, ::bound} = object;

which could be written without destructuring, but with the bind operator strawman, as

    var unbound = object.unbound, bound = ::object.bound;
+1, if that syntax works, that's fine for me :-)

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to