-
Notifications
You must be signed in to change notification settings - Fork 65
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 set_external(const Node &data)? #97
Comments
I like this idea… I’m not sure how you would implement the const version… If it’s const, does that mean that the entire node’s subtree is const? how is the constness ‘stored’ in the node?
From: Cyrus Harrison <notifications@github.com<mailto:notifications@github.com>>
Reply-To: LLNL/conduit <reply@reply.github.com<mailto:reply@reply.github.com>>
Date: Tuesday, November 29, 2016 at 2:54 PM
To: LLNL/conduit <conduit@noreply.github.com<mailto:conduit@noreply.github.com>>
Subject: [LLNL/conduit] support set_external(const Node &data)? (#97)
set_external(Node &) effectively allows you to create a shallow copy the passed node.
Since it does not modify the structure of the passed Node, I think we should also support a variant that allows the passed node to be const.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#97>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ARGiBBn_8Pvf6jD7COuMBsmFb0HLJqMMks5rDK0sgaJpZM4K_lto>.
|
we already do have a const interface that prevents any changes from the structure of a node. That is what we would be abiding by in this case for the input data. There are limits to the power of constness here, depending on what aspects of the interface are used we can actually guard against data changes. Pointers can only be accessed as const type * pointers, etc. In this case, the new node could still modify values if it is used in a non const manner, but there is a contract not to modify the passed tree. |
Then that sounds awesome!
…-Adam
From: Cyrus Harrison <notifications@github.com<mailto:notifications@github.com>>
Reply-To: LLNL/conduit <reply@reply.github.com<mailto:reply@reply.github.com>>
Date: Wednesday, November 30, 2016 at 9:04 AM
To: LLNL/conduit <conduit@noreply.github.com<mailto:conduit@noreply.github.com>>
Cc: Adam Kunen <kunen1@llnl.gov<mailto:kunen1@llnl.gov>>, Comment <comment@noreply.github.com<mailto:comment@noreply.github.com>>
Subject: Re: [LLNL/conduit] support set_external(const Node &data)? (#97)
we already do have a const interface that prevents any changes from the structure of a node.
This allows you to iterate over the values (using const iterators, etc) but disables any dynamic changes to the node tree.
That is what we would be abiding by in this case for the input data.
There are limits to the power of constness here, depending on what aspects of the interface are used we can actually guard against data changes. Pointers can only be accessed as const type * pointers, etc.
In this case, the new node could still modify values if it is used in a non const manner, but there is a contract not to modify the passed tree.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#97 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ARGiBOMuY13IkCXzCqS3SWEV8uksX1Ymks5rDaylgaJpZM4K_lto>.
|
resolved in pr #111 |
set_external(Node &) effectively allows you to create a shallow copy the passed node.
Since it does not modify the structure of the passed Node, I think we should also support a variant that allows the passed node to be const.
The text was updated successfully, but these errors were encountered: