Hacker News new | ask | show | jobs
by fauigerzigerk 2325 days ago
What unnecessary boilerplate is obviated by callable objects in a language that already has closures?
1 comments

Having to wrap every use of whatever method in a closure when you could just pass the object itself eg

    (map (fn [x] (get m x)) a-vec)
Would usually be

    (map m a-vec)
That's not a fair comparison. You don't have to wrap every use of your method in a closure any more than you have to call the constructor of your callable class on every use.

You have to bind your state to a function exactly once in both cases.

Your example just happens to omit the constructor call required to create the callable object while you are showing the code to create the closure.