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

Disable anchor/alias completely #3

Open
neolee opened this issue Feb 7, 2013 · 2 comments
Open

Disable anchor/alias completely #3

neolee opened this issue Feb 7, 2013 · 2 comments

Comments

@neolee
Copy link
Contributor

neolee commented Feb 7, 2013

YACYAML is amazing YAML parser/omitter for Objective-C! The only concern I have now is the automatic Anchor/Alias mechanism. In some of my cases I want to completely disable this feature, any chance?

@th-in-gs
Copy link
Owner

th-in-gs commented Feb 7, 2013

As I guess you've found, it's possible to disable anchors for scalers (in fact it's the default - the "YACYAMLKeyedArchiverOptionAllowScalarAnchors" flag turns on anchor emission for scalars).

With arbitrary objects, the problem is that the emitter would infinite-loop if there were any cycles in the object graph, emitting an infinite amount of increasingly nested data as it keeps following the cycle infinitely.

If your concern is the cost of all the hashing and potential comparisons (to find out if every emitted object is equal to an already emitted one), you can turn on "YACYAMLKeyedArchiverOptionDontUseObjectEquality" and then the emitter will only emit anchors for objects that are the /same/ object as one seen before (i.e. at the same address in memory), rather than if they're 'isEqual:'-equal to an object that's been seen before.

Having said all that, if you have a real need for this, I would not be opposed to a "YACYAMLKeyedArchiverOptionDontEmitAnchors" option (with the caveat that it might infinite loop and produce endless output if used incorrectly, as mentioned above).

@neolee
Copy link
Contributor Author

neolee commented Feb 7, 2013

Thanks a lot for your rapidly and nicely written feedback. My concern is
the readability. I am working on some configuration files of third party
system. Consider the following data structure:

applications:
app1:
config1: true
config2: true
app2:
config1: true
config2: true
......

Applying anchor/alias on these data will sacrifice the overall readability
in my opinion. So if possible an option disable alias completely I will
very be appreciated. Thanks again for rely.

On Thursday, February 7, 2013, James Montgomerie wrote:

As I guess you've found, it's possible to disable anchors for scalers (in
fact it's the default - the "YACYAMLKeyedArchiverOptionAllowScalarAnchors"
flag turns on anchor emission for scalars).

With arbitrary objects, the problem is that the emitter would
infinite-loop if there were any cycles in the object graph, emitting an
infinite amount of increasingly nested data ad it keeps following the cycle
infinitely.

If your concern is the cost of all the hashing and potential comparisons
(to find out if every emitted object is equal to an already emitted one),
you can turn on "YACYAMLKeyedArchiverOptionDontUseObjectEquality" and then
the emitter will only emit anchors for objects that are the /same/ object
as one seen before (i.e. at the same address in memory), rather than if
they're 'isEqual:'-equal to an object that's been seen before.

Having said all that, if you have a real need for this, I would not be
opposed to a "YACYAMLKeyedArchiverOptionDontEmitAnchors" option (with the
caveat that it might infinite loop and produce endless output if used
incorrectly, as mentioned above).


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-13229526.

No, I will not fix your computer!

[email protected]

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