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

Support for cyclic data #71

Open
jkroso opened this issue Apr 24, 2016 · 2 comments
Open

Support for cyclic data #71

jkroso opened this issue Apr 24, 2016 · 2 comments

Comments

@jkroso
Copy link

jkroso commented Apr 24, 2016

One good syntax I have found for references is # 1, # 2, etc.. where the number is the index of the object being referred to as it would be encountered when parsing the input stream of EDN. As far as I know this would otherwise be a syntax error so implementations are free to support it without potentially misinterpreting otherwise valid data.

I know this comes at a performance cost so I don't expect it to become a compulsory part of the spec. It just took me a few goes to arrive at it so I thought I should put it out there to potentially save others some failed attempts.

@kengruven
Copy link

The Common Lisp reader lets you tag anything with a number like #1= and then reference it later with #1#. It's neat, though I've used it maybe once ever. The arbitrary references make it easy to refer to other objects at any level of the hierarchy, and I suspect it minimizes the performance cost you mention, as the reader only needs to keep references to objects which were explicitly tagged.

But as cool as it is, I'm not sure I see the value for EDN, which says it's purely "for the conveyance of values", not objects. Doesn't cyclic data only make sense in the context of objects?

@jkroso
Copy link
Author

jkroso commented Sep 20, 2018

says it's purely "for the conveyance of values", not objects

Depends how you define values and objects I guess. But whenever one thing has a relationship with another thing the later usually has a relationship with the former too. e.g books have authors and authors have books.

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

No branches or pull requests

2 participants