Thanks to visit codestin.com
Credit goes to github.com

Skip to content

switch order of arguments to R.repeatN#626

Merged
davidchambers merged 1 commit intoramda:masterfrom
davidchambers:repeat-n
Dec 2, 2014
Merged

switch order of arguments to R.repeatN#626
davidchambers merged 1 commit intoramda:masterfrom
davidchambers:repeat-n

Conversation

@davidchambers
Copy link
Member

Every other xxxN function takes the N as the first argument:

$ grep 'R[.].*N =' ramda.js
    var curryN = R.curryN = function curryN(length, fn) {
    var invokerN = R.invokerN = function invokerN(arity, method) {
    R.argN = function argN(n) {
    R.repeatN = _curry2(function repeatN(n, value) {
    var constructN = R.constructN = _curry2(function constructN(n, Fn) {
    var liftN = R.liftN = _curry2(function liftN(arity, fn) {

I can't imagine partially applying R.repeatN very often. (Please correct me if I'm wrong!) This being the case, we should switch the argument order so all the xxxN functions take the N as the first argument.

@buzzdecafe
Copy link
Member

👍

🌵

davidchambers added a commit that referenced this pull request Dec 2, 2014
switch order of arguments to R.repeatN
@davidchambers davidchambers merged commit 56a5d4f into ramda:master Dec 2, 2014
@davidchambers davidchambers deleted the repeat-n branch December 2, 2014 16:41
@CrossEye
Copy link
Member

CrossEye commented Dec 2, 2014

👎 Unlike the others on this list, this is the only one that actually makes sense curried, And if it's used that way, I would guess that nCopiesOfFoo is the more likely desire than fiveCopiesOfVal.

@davidchambers: You've been our strongest advocate for consistency, and I admire that. But I think there is a more important consistency here than "where parameter n goes", and that is the one that says our parameters are ordered from the least likely to change to the most likely to change, for the best experience possible with currying. In rare cases (prop/propOf), we'll expand our API when that choice isn't obvious.

@CrossEye
Copy link
Member

CrossEye commented Dec 2, 2014

Damn, A few seconds late.

Sorry, I've been both sick, and lacking Internet, managing to see a few issues on my phone, but not really to engage.

@davidchambers
Copy link
Member Author

In that case, how about we revert to the old behaviour but rename the function R.repeat? As with a function like R.take, it's clear that one of the arguments must be an N. We can thus keep the preferred argument order while making the xxxN family consistent.

@CrossEye
Copy link
Member

CrossEye commented Dec 2, 2014

No objections.

I like your focus on naming consistency; it's kind of like having JDD around to poke us on performance here and there: While I know you're almost always thinking about these things right, it's often not something I would have thought about myself.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants