Re: Terminology: “non-method function”

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Apr 11 10:04:54 PDT 2012


(corrected a pretty obvious typo in the first sentence)

On Apr 11, 2012, at 7:12 AM, Peter van der Zee wrote:

> On Wed, Apr 11, 2012 at 1:01 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
>> What is a good term for functions that don’t have/use dynamic `this`?
> 
> A bound function?

I'm leaning in that direction.  A unbound function has an unbound (dynamic) this while a bound function has a bound (fixed) this.

To further clarify this it might be useful to better differentiate  binding this from currying the arguments.

We might do this by adding a new Function.prototype.curry function that doesn't have a this value as its first argument.

You would then
 fn.curry(1,2)

If you want to create a curried function from fn with 1 and 2 as the first two fn arguments. And:

 fn.bind(foo)

if you want to create a bound version of fn where this is bound to the value of foo.

The semantics of 

   fn.bind(foo,1,2)

could then be explained as being equivalent to 

   fn.bind(foo).curry(1,2)

Allen






More information about the es-discuss mailing list