-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add recursive conversion routines? #122
Comments
Usually, the Javascript language only provide functions to superficial transformation, for example, Object.assign() only work into the first level and don't work recursively into next object levels. A good recursive function should be to work with circular references and other complex situations. JSON.stringify () is the only function that works in depth and has serious problems with circular reference situations. In my experience (I've developed a recursive immutability library https://www.todojs.com/datos-inmutables-en-javascript/ ) it's more idiomatic that maintained built-in functions are kept at the superficial level. |
I think this could be left to another proposal, if necessary. It might be safer to have this proposal land without this feature first, and then see how it goes, maybe? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The point is that having recursive conversion routines makes a cleaner record literal syntax comprehensible rather than confusing. This is an on-topic response to the request in OP, making a case in favor of adding recursive conversion. The original post is here, with only a brief mention added to #10 (before I had to answer to what seems like knee-jerk responses from the past syntax discussion). |
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. |
Various people have raised the feature request that a recursive conversion routine should be built-in, to convert structures of Objects and Arrays to Records and Tuples. Lots of JS immutable data structure libraries have this capability.
The current draft proposal does not contain recursive conversion routines, though of course they can be implemented in JS. I think these are often used inappropriately (e.g., to clone, which should be unnecessary), and I'm not convinced we should encourage this pattern with a built-in function.
I'd be open to adding this, if we have good use cases. One option is that we could make a depth limit parameter, as the README suggests. I'm not sure if this would result in feeling too low-level, though (and people could always get around it by using a large value...).
cc @rauschma
The text was updated successfully, but these errors were encountered: