Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Good question. Let's re-arrange the get method a bit to make it easier for currying demonstration.

    function get (propertyName, object) {
        return object[propertyName];
    }
The method 'get' does what it's named, to get the property now in the call. Curry(get('age')) creates a separate entity that parameterizes get with the 'age' property. It's a new function object different from get. But at least the term curry(get('age')) gives some visual cue to the code readers as what it does vs just get('age').

For languages (e.g. Haskell) that implicitly curry everything, it's understood that any missing parameter means a curried function has been created and the actual call is deferred. Javascript is not such language. Mixing in the naming convention for implicit curry just causes confusion for the readers.

Javascript's currying is explicit with pattern such as, getter(get, 'age'), which would wrap a function around the get function with a closure {propertyName: 'age'}.

I think it's best to consider the audience and the convention of a language when naming things.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: