extension mechanism for nodes

I'm trying to add an extension mechanism to nodes, i.e. a sandbox solution node will be extending another node and all of the extended node's properties are copied to the extending node through a reference defined in the structure.
However, when I change one of the copied properties, the actual one is also changed. How can I avoid this?

So, above is a very very basic sketch of the problem, when B's name is changed, A's name is also changed. I think there needs to be an encapsulation to avoid modifications.
Comment actions Permalink
I'm afraid you are not copying the properties, but instead reusing the A's properties through the reference.
Comment actions Permalink
I made a mistake for using the word "copy". I know I'm reusing it, and I want to do so, what I want to do is: whenever A is changed B should change as well without any modification. But if a reused property in B is modified, it shouldn't be affecting A's property.
I'm sorry for misinterpretation.
Comment actions Permalink
I can't see a mechanism that could do this automatically for you. Maybe a concrete use-case that motivated you could help me envision a solution.
The closest parallel I found is the extension mechanism for classes in BaseLanguage - a class B can extend a class A and so inherit its "members". You explicitly "override" the "members" of the parent. The "members" are, however, children of the ClassConcept concept, not properties, so you can refer to them directly from the overriding "members".
Perhaps something along these lines could be used for your case.
Comment actions Permalink
If I understand correctly, you would like to have copy-on-write for properties. I could think of this solution, although it seems quite bizarre.
You define properties in both concepts A and B. You maintain yet another property in B which is boolean hasBeenCopied. And I assume that you have a reference in B to the node A. You use getters and setters for the derived properties in B and they look like this
  getter(): if hasBeenCopied
              then this.property
              else refToBNode.property
  setter(value): this.property = value
  this.hasBeenCopied = true
Hope this helps. But it would be nice to know what your use-case is.

Please sign in to leave a comment.