-
Notifications
You must be signed in to change notification settings - Fork 624
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
BREAKING(std/collections): remove distinct and union #1099
BREAKING(std/collections): remove distinct and union #1099
Conversation
I disagree with this change:
|
This is a common pattern for distinct values.
Disagree.
It is sugar, so it is exactly the same functionality.
std should not implement sugar functions for trivial cases, therefore causing the issue of being a counter example.
not very likely, more likely that optimization is going to happen under the hood imo. |
Not to a beginner(not with Deno, with JS/TS in general), especially if we're trying to target them more (as seen in the controversial
I think you misunderstood what I was trying to say, seeing
Again, I think you misunderstood, it's much easier to accidentally forget to
Not sure what you mean by "being a counter example" in this context could you elaborate?
/shrug js could get new features that make this more optimize-able, the possibility is there and worth accounting for. |
There has been a lot of discussion around the I also want to add that while I understand the idea, a PR that just removes things that have just been merged as the result of a long process with discussions, reviews and several people, leaves a weird aftertaste with me personally. |
I do not think it is right to remove them with a simple PR without discussions. However, I think it's still worth revisiting if they should stay in std. Here are some points that I think are very valid: 1. They abstract simple one-linersconst uniques = [...new Set(arr)]; is a very common pattern to get unique values out of an array, and I'll even argue that this is even more elegant and readable than While it is debatable, but the general trend in js is to let these trivial abstractions created before ES6 go and to use their ES6 counterpart [1][2]. Including them in 2. This does not seem to align with the general direction of std-wgWhile there is no clear consensus on the scope of People can use something like https://deno.land/x/[email protected] if they really want these helpers. 3. We should not do stuff that might be deprecated in the futureThere is already a stage 2 proposal for tldrI think there's a case to be made and we should discuss it further. |
You can't import the published lodash from /x/(kinda weird that it's still there but it is what it is), you have to import it from skypack or something similar.
It's not really that obvious to a beginner imho(and as seen by the remove type-checking by default, we're attempting to target beginners). You go and look up "how to get all the unique values in an array javascript" first post you get is: https://stackoverflow.com/q/1960473/14560865, which the accepted answer has some non-modern versions, with this pattern at the very bottom of it, the original question also links to: https://stackoverflow.com/q/9229645/14560865 and https://stackoverflow.com/q/1960473/14560865, one of which is not very modern and one which uses jquery.
Could say the same thing about the entirety of And removing stuff when they don't really hurt anyone and has multiple benefits to their existence(see my earlier comment) because they're easily available in 3rd party modules or there's a proposal for it leaves std in a really weird position, because you could make the same case for some parts of std( |
@zhangyuannie sorry this got really long - I am just repeating myself in different channels a lot in very similir discussions and wanted to be a bit more thorough to be able to link to this. I hope you are not feeling like I am ranting at you :-) There has been a long discussion in discord about this, see this message and everything above it . It touches a lot of the points. The biggest problem here is that many people seem to have strong-ish conceptions about the philosophy behind In the end, I think the discussion behind this is a lot more about general For the functions, I can just repeat what I said in the discussion leading to the first message above. To reiterate:
|
While I'm sympathetic to the argument made by @timreichen, these functions have been discussed at length, both in the proposal and in Discord, and I think they bring a semantic value that outweighs the fact that the implementation is so simple. For now we'll keep them in the std lib. |
distinct
andunion
are sugar functions for trivial one-linersdistinct
union
and should therefore be removed from std/collections