-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Curry placeholder should play nice with other Ramda's and other libs #1052
Comments
It was apparently quite hard for me to get the title right :( |
perhaps we should use a |
🌿 I like this idea a lot. For some time our placeholder was |
Using a symbol sounds like a great idea. The only question is what to call it. |
something like |
My opinion:
|
fair enough @paldepind , maybe |
I think namespacing symbol names is a good idea, so I would vote for |
Sorry. I don't know how I missed this.... I still vote for namespacing though :) |
I think |
I'm having a hard time coming up with a reason why it would be beneficial to define the placeholder in a cross-library way... Why would you use a different currying library that works with the ramda placeholder? That said, if that is the goal, I would prefer something more descriptive, like I'm not going to fight for it though. I'll stay quiet now :) |
There is a myriad of curry libraries in JavaScript. As far as I know only Ramda supports placeholders. But it's a powerful idea so one day some other library might implement the same feature. For the sake of my argument let's assume that ExtremeCurry implements placeholders as well. I'm writing a program and I really like functional programming so I'm using Ramda and some functional library for dealing with time. All functions in this library are advertised as being curried. The author choose to do so using ExtremeCurry but I as an end user does now know that. So I happily try to pass along my placeholder (R.__) to one of the functions from the time library. This doesn't work. But if both Ramda and ExtremeCurry had used the same placeholder there would be no issue. All curried libraries could of course expose their own placeholder but not having to do that would be nicer IMO. Naming it |
I get where you are coming from... It could potentially be useful at some point in the future. My hesitation is mostly claiming a symbol name without namespacing. If you want to use Symbols in a cross library way, you'd have to look it up in the global symbol table using something like If you punted and just used a magic string (which you would have to do anyway, unless you polyfill) instead of claiming a global Symbol, my hesitation would be greatly diminished. |
I see. That is a valid concern. My best suggestions are |
perhaps we should follow the practice of browser makers and prefix our names with our own namespace (viz. |
If someone takes a decision about the name I will do a PR. I don't care much but I still think we should invent our own standard. My only reason for doing so would be that I could write something like "all functions in libraryFoo are curried and they accept placeholders as specified in The One An Only Curry Placeholder Standard" in my libraries that uses the Ramda curry function like this. |
that seems reasonable to me. Either (Frankly, if I had my druthers, I'd pull the placeholder out completely. But I'm pretty sure my druthers would be overruled.) |
👍
I don't have a major objection to the way it is now. I want the abilities we have there, and the only alternative I see to the placeholder is the, admittedly more powerful, but also more complex, idea that lodash has of |
Complex? In usage? Implementing |
Yes. Implementations are quite easy, as you demonstrate. But whereas I easily understand what And I'm afraid there's a similar problem with a possible |
I like the placeholder and use it extensively, I think it's really easy to see what's the programmer's intent is with it. I find it more readable than |
I'm mixed. I don't particularly like the placeholder. I simply don't see anything better. The point I was making, though, is that var g = rearg([2, 0, 1], f); I'm just not sure that buys us anything over the lambda: var g = function(a, b, c) {return f(b, c, a);}; Certainly it's shorter, but to me it's much less readable. |
I personally don't find code written with neither |
I find
My Forth is so long ago and not well-remembered. But |
Currently the Ramda
__
-placeholder is defined like this:And it is checked for at various places with strict equality:
Now, consider what happens if I'm using
npm
to manage dependencies and I'm using a library,someFnLibDepOnOldRamda
, that depends on a slightly different version of Ramda than the one I'm using myself. Thennpm
will pull in two different versions of Ramda and with them two different instances of__
. Thus the strict equality check that Ramda uses breaks.If pass my instance of
__
to a function from the library, curried with it's Ramda's curry it will not be recognized as a placeholder. Bam! I now have an obscure confusing bug :(One solution: Define this placeholder like this:
And check for it like this:
In particular the name
someSpecialPropertyName
should not include the word "ramda". This would make it more natural for potential other curry implementations to adopt the same placeholder "specification".The text was updated successfully, but these errors were encountered: