Skip to content
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

Should the various Record.{keys/values/entries/assign} namespace methods exist? #133

Closed
rickbutton opened this issue Jun 16, 2020 · 5 comments

Comments

@rickbutton
Copy link
Member

All of the Record namespace methods (with the exception of isRecord) are simply duplicates of the existing Object.____ counterparts, but returning records/tuples instead of objects/arrays. Should these be included in the initial proposal?

The champion group's current opinion is that they should be omitted, and evaluated individually in the future, as these will be extremely simple to specify in the future, but I am also interested in community feedback.

@papb
Copy link

papb commented Jun 16, 2020

Usually, I am in favor of keeping a proposal as minimal as possible. Indeed these methods could be added later easily, without breaking the internet and all that. However, I think at least keys, values and entries could be already included. They are very straightforward, right? Could there be any room for debate on how they should behave? Or any other gotcha? I don't see any...

For assign, on the other hand, I am not so sure. My intuition tells me that there is some room for debate on whether or not it should exist, how exactly it should work, if it could take a mutable object as input or not, and such... Since Object.assign mutates the first argument, there seems to be some room for debate. I can imagine people discussing what would be the best for it, and also requesting other utility methods along the way (brainstorm: Record.without for example?) Therefore I agree postponing it would be beneficial.

@rickbutton
Copy link
Member Author

On keys/values/entries, spec-wise they are extremely simple. However, we have to weigh the additional burden of more methods in the language against the fact that they are more or less sugar for Tuple.from(Object.keys(#{ a: 1 })).

Now that we have spread syntax, there is nothing that Record.assign could do that a simple spread cannot (since you can spread anything into a record, it will just work).

@littledan
Copy link
Member

The thing about Record.keys, Record.values and Record.entries is that they wouldn't have anything to do with Records. They'd do the same thing as the Object ones, except return Tuples instead of Arrays. The same keys/values/entries algorithms work across objects and Records.

@papb
Copy link

papb commented Jun 16, 2020

Ah, these are great points. I am convinced - I think they can all be left to another proposal then 😬

@rricard
Copy link
Member

rricard commented Jul 8, 2022

In order to focus on changes that are necessary to finish this proposal, we are closing issues related to follow-on proposals. You are free to continue the discussion here and reference it in other venues.

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

No branches or pull requests

4 participants