Le 18/10/2013 07:19, Angus Croll a écrit :
I couldn't find a commitment to a specific syntax in the latest ES6 standard
The latest official news is in the May 2013 TC39 notes:
https://github.com/rwaldron/tc39-notes/blob/master/es6/2013-05/may-21.md#44-proxies
The final design of proxies is the "direct proxies" design. As Tom said, a proxy is now created doing:
    var p = Proxy(target, handler)

Proxy.create and Proxy.createFunction are aimed at disappearing.

Gecko, chrome experimental, traceur and 'node --harmony-proxies' support the Proxy.create syntax (detailed in http://wiki.ecmascript.org/doku.php?id=harmony:proxies)

e.g.
var proxy = Proxy.create({
 get: function(p, n) {
  return 'Hello ' + n;
 }
});
proxy.World //'Hello World'
On the SpiderMonkey (Gecko implements the DOM and other platform APIs and SpiderMonkey is the part that implement ECMAScript) side, I filed a bug to get rid of these as it's indeed confusing to have both APIs exposed in web pages:
https://bugzilla.mozilla.org/show_bug.cgi?id=892903

IIRC, the V8 team had started implementing something (behind a flag), and then wars on Proxy design happened, so they chose to wait for the design to stabilize. Now may be a good time to restart

However MDN calls the above the 'Old Proxy API'.
I'm glad I succeeded in, at least, making people wonder what that was all about :-)

Since I've been following closely the design of proxies, I documented them on MDN. Especially after the implementation of direct proxies in Firefox (where I moved the documentation of the previous API to its own page and try to explain the best I could that people should not use it). I'm happy to improve the doc if something isn't clear (on the feature itself or clarify the current technico-social mess of different APIs in the wild).

As a side note, to my knowledge, the only native implementation of direct proxies is in Firefox, but it's incomplete and has known bugs. You can see the known limitations and bugs here: https://bugzilla.mozilla.org/showdependencytree.cgi?id=703537&hide_resolved=1 ("depends on" section. Bug 787710 is particularly funny :-)).

If you want to play with proxies, I think that the most faithful-to-the-spec implementation is Tom's polyfill: https://github.com/tvcutsem/harmony-reflect/blob/master/reflect.js where he's using the old API where available to implement the new one.

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

Reply via email to