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 set_external(const Node &data)? #97

Closed
cyrush opened this issue Nov 29, 2016 · 4 comments
Closed

support set_external(const Node &data)? #97

cyrush opened this issue Nov 29, 2016 · 4 comments
Labels
Milestone

Comments

@cyrush
Copy link
Member

cyrush commented Nov 29, 2016

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.

@cyrush cyrush added the design label Nov 29, 2016
@cyrush cyrush added this to the 0.2.1 milestone Nov 29, 2016
@ajkunen
Copy link
Contributor

ajkunen commented Nov 30, 2016 via email

@cyrush
Copy link
Member Author

cyrush commented Nov 30, 2016

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.

@ajkunen
Copy link
Contributor

ajkunen commented Nov 30, 2016 via email

@cyrush
Copy link
Member Author

cyrush commented Dec 8, 2016

resolved in pr #111

@cyrush cyrush closed this as completed Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants