Scoped binding of a method to an object

Russell Leggett russell.leggett at gmail.com
Tue Oct 15 13:02:56 PDT 2013


> Using your proposed "underscore2" (OO-underscore?) with :: is no more
> verbose than underscore.js (underscore1), and it has the chaining not
> inside-out-composing win some may prefer.
>

I'm glad you noticed the 2. Perhaps oonderscore? :)


>
> We should not argue only about taste, and bind (::) has a champion and
> good rationale as an addition to the language.
>
> What I think we should argue about is whether SOE that solves either or
> both problems (P1 and P2) I identified is even possible. Andreas's
> static-only resolution requirement is good. Anyone want to work on that
> angle?


If we do assume static-only resolution, isn't that trivial to show its
impossible? Wouldn't it require complete type inference? And even then,
what about expressions that evaluate to more than one type?

Btw, another thing I noticed, thinking about using the binding operator
this way, is that it's also a perfect fit for array-likes and array methods.

    import {hide} from "jQuoory";
    let {filter, forEach} = Array.prototype;
    document.getElementsByClassName('hello')
        ::filter(e => e.tagName === "span")
        ::forEach(e => e::hide());

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


More information about the es-discuss mailing list