-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need better names for two types of method extraction #13
Comments
call-bind, not call-this :-) I'm confused why these need names. How you get to |
Another way of saying it is, what I call "method extraction" is "call-bind a receiver-sensitive function, and cache it for later-run code". A syntactic |
Yeah, I’m just looking for a precise way to refer to the non-goal of not repeating ourselves when we do As you know, the old proposal allowed this with its unary form, But I don’t want to call that non-goal simply “method extraction”. Some people may reasonably argue that this proposal does functionally address “method extraction”, in that we can extract method functions and then use them ( My concern about this confusion comes from #12 (comment) by theScottyJam:
My concern is that, if we say, “Method extraction is a non-goal of this proposal,” then some other people will also think erroneously that that non-goal includes |
Hmm, I see what you mean. "Implicitly binding the receiver at extraction time is a non-goal of this proposal"? |
Method extraction (along with the calling of extracted methods) is a core use case of this proposal. For example, method extraction is essential for security from prototype pollution and other global mutation.
However, a non-goal of this proposal is what I currently call “tacit method extraction”: a (confusing) term I made up to refer to when a method is implicitly bound to its original owner, creating a bound function.
(Note that “tacit” method extraction is only useful on instance objects; it would not be useful on prototype objects, because calling a method on a prototype object is not very useful. In contrast, “explicit” method extraction is useful on prototype objects; the extracted prototype method could then be called on.)
I think these two concepts could use better names than “explicit” versus “tacit”. I don’t really have any other ideas, though.
(There’s even a third type of method extraction called “call-binding”, in which the
this
binding gets “uncurried” into a new (bound) function, usingfn.call.bind
, so thatthis
is once again supplied at the call. @ljharb’scall-thiscall-bind library does this; Node’s primordials also use this pattern. I don’t even want to think about how they should fit in our nomenclature.)The text was updated successfully, but these errors were encountered: