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
R.noop #701
Comments
|
|
@buzzdecafe How did you mean in #596 that |
IMO |
@buzzdecafe It doesn't do anything, hence its name. :) I understand your argument but I still think that a function that doesn't do anything has its place in a functional library like Ramda. A good example scenario is the one I provided on the top of this thread. Even some non-functional libraries like Angular include it - https://docs.angularjs.org/api/ng/function/angular.noop |
I certainly see the utility of |
Well, I guess I'm out of arguments. For me this comes down to practicality but your reasoning is certainly more nuanced. I can continue to use |
anyone else have $0.02? @CrossEye ? @davidchambers ? Bueller? |
I added |
What are its arguments? What does it return? Is it idempotent? Does it mutate input objects? 😄 I also don't feel strongly. It feels very strange to have a function with no return value inside Ramda. And anyone who wants this can add it easily. We haven't tried to do anything like the extension mechanism that Lo-Dash uses, but it would be trivial for anyone to use Ramda's exposed object as a namespace, I suppose, to add such things as this if they wanted:
But there are clearly times when it's useful. I probably would not reject a PR (although perhaps @buzzdecafe would.) But I wouldn't be excited by one. |
if no one wants to fight for it, i'm gonna close it |
I'd like that function since it makes the use case below was easier: var noop = () => undefined
R.cond(
[R.eq('Known Error 1'), noop],
[R.eq('Known Error 2'), noop],
// something we don't expect and thus want to log
[R.T, error => error]
)('Known Error 1')
// instead of
R.cond(
[R.not(
R.anyPass([
R.eq('Known Error 1'),
R.eq('Known Error 2')
])
), error => error]
)('Known Error 1') the noop function would ignore all arguments, return undefined and have no side effects, basically be |
There are three questions:
Clearly it's useful. I use some version of it often. But I don't think it fits well with Ramda. Ramda is about dealing with values. This would be very much an oddball function in Ramda. And it's very easy to create, either manually, as you've done in your example, or with Ramda:
If you want to use ramda's
I don't have a serious objection to this; it simply doesn't feel like a good fit. |
I don't think that the "it's easy to create" argument is a valid one. I personally rather don't want to extend libraries in any ways because later on a developer can come along looking up the library reference and (s)he won't find the function that I added, leading to confusion. |
I don't think that is especially persuasive either. IMO the best arguments are:
|
I absolutely agree that "ramda should be about evaluating expressions, as opposed to performing operations." (So it's at least argumentum ab auctoritate nostra.) |
Ok, convinced :) |
@despairblue and anybody getting to this thread...noop is available in Ramda Adjunct |
... and Ramda-extension for really long time |
@tommmyy OMG I had no idea about this project, thanks :) |
It'd be useful to have a function that doesn't do anything.
Could be used in scenarios like:
The text was updated successfully, but these errors were encountered: