-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function modifiers to take function as last argument #25
Comments
Switch argument order of throttle arguments |
There are further functions such as apply that also break this rule |
I'm confused as to why you would want to switch all methods to have function be last argument. Making methods take their data as the last argument is what makes methods composable, and is the very reason why underscore/lodash is unsuitable for functional programming. Maybe I am mistaken on the intention of this issue? |
I think it depends how you are composing, I think. If all functions are curried then having a function as last args means you can do the following. var throttleToMyLimit = throttle(100);
var logIt = throttleToMyLimit(console.log); |
Although I think it might make sense to have a function with the arguments reversed so |
This is very different from the direction we took with Ramda, and I'm trying to see the advantage. To me the order is straightforward: from the parameter least likely to change to the one most likely to change. A simple example is var squareAll = map(square) ;
squareAll([1, 2, 3]): //=> [1, 4, 9]
squareAll([4, 5, 6]); //=> [16, 25, 36] than does this: var map123 = map ([1, 2, 3]);
map123(square) ; //=> [1, 4, 9]
map123(add(1)); //=> [2, 3, 4] So the transformation function should be the first parameter and the list of values second. And most every function works this way. |
@CrossEye I agree with what you are saying there. I think the same logic applies(although the terms might get more confusing) with functions on functions. If you have a library of higer-order functions who's purpose is to modify other raw functions then the raw function to be modified should be supplied as the last parameter. So in the example of throttle it make sense to me to be var throttle100 = throttle(100);
throttle100(rawFunction); |
I think I was reacting more to the title than to your example. Carry on. Don't mind me. 😄 |
By default function should be passed as last argument.
Work out how to setup changelog
The text was updated successfully, but these errors were encountered: