RE: Terminology: “non-method function”

Domenic Denicola domenic at domenicdenicola.com
Wed Apr 11 09:56:23 PDT 2012


We use `Function.prototype.partial` in our codebase. We consider `Function.prototype.papply` but thought that would be too confusing with `Function.prototype.apply`.

________________________________
From: es-discuss-bounces at mozilla.org [es-discuss-bounces at mozilla.org] on behalf of Axel Rauschmayer [axel at rauschma.de]
Sent: Wednesday, April 11, 2012 12:54
To: Allen Wirfs-Brock
Cc: es-discuss
Subject: Re: Terminology: “non-method function”

Great idea. Do we need similar this-less variants for call and apply? Probably not, the former is just a normal function call. The latter can by handled by the spread operator.

IIRC, what one actually does here is not currying, but partial application. However, I don’t see any good method name being derived from “partial application”.


On Apr 11, 2012, at 18:44 , Allen Wirfs-Brock wrote:


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<mailto: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 bound 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 created 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






--
Dr. Axel Rauschmayer
axel at rauschma.de<mailto:axel at rauschma.de>

home: rauschma.de<http://rauschma.de>
twitter: twitter.com/rauschma<http://twitter.com/rauschma>
blog: 2ality.com<http://2ality.com>

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


More information about the es-discuss mailing list