Browse files


  • Loading branch information...
1 parent 98be7fe commit 0ae7d9849f6e2d5729ca674e383f2bcaf35d92d1 @raganwald raganwald committed Jan 5, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 2013/01/
@@ -2,8 +2,6 @@
What is *partial application*? And most importantly, why do we care about it?
-![What are the applications?](
## Recap
First, a quick recap (You can skip this if you're familiar with functions in JavaScript). Just about everything here applies to CoffeeScript as well, except for some folderol about handling multiple arguments. And everything except `this` applies to just about any programming language that supports functions as first class objects.
@@ -74,7 +72,7 @@ function ellipses (fn) {
var variadic = ellipses;
+[![Nixie Clock Case]](
## What is Partial Application?
@@ -220,6 +218,8 @@ Reference.prototype.decrementReferenceCount = function () {
We still have two functions, but one of them is now a general decrementer that can be used elsewhere. Is this important? Possibly! Is it handy? Very much so when DRYing up code. And you can use this technique with filter/select, with reduce, and anything else working over collections.
+[![Innards of telephone at the station on the Gwili Railway](](
## Another Partial Application with Binding Semantics
Languages that don't do anything special with `this` are quite happy with a few forms of partial application. JavaScript needs a few more in very large part because of the importance of managing `this` when working with objects. This function, `send`, is useful for mapping over objects by sending them a message. It emulates Ruby's `Symbol#to_proc` with some extra partial application goodness. For our purposes, the implementation is:
@@ -272,6 +272,8 @@ Which leads us to:
Reference.decrementCounts = splat(send('decrementReferenceCount'));
+![What are the applications?](
## Conclusion
**Partial application is what allows us to abstract away a lot of function scaffolding, in large part because it's a compact way to decompose functions**.

0 comments on commit 0ae7d98

Please sign in to comment.