Scoped binding of a method to an object

Russell Leggett russell.leggett at gmail.com
Mon Oct 14 12:51:44 PDT 2013


I get that this isn't really the same, but I think one really viable
solution for the scoped method problem (which is really just the expression
problem, right?) is the proposed bind operator
http://wiki.ecmascript.org/doku.php?id=strawman:bind_operator

It doesn't use dots, so it won't mask the difference between the normal
prototype chain with some additional scoped binding (for good or ill), but
along with it comes the clarity and comfort of lexical binding and also the
potential use of the module system.

    import {shuffle,each,filter} from "underscore2";

    myArray::shuffle();

And if that isn't enough because you need more polymorphic behavior, I
think something like Clojure's protocols
<http://clojure.org/protocols>could be implemented as a library to be
used in conjunction.

- Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131014/bc7f3d2e/attachment.html>


More information about the es-discuss mailing list