children versus references

I'm a little confused about the difference between references and children. I thought it was something similar to composition versus aggregation in UML, but then I realized that a concept cannot reference 0..n instances of a given concept.

Also, how do I model a 0..1:0..n relationship between 2 concepts and make sure that MPS knows about which child (or reference) is reverse of which child or reference in the target concept.

For example, back to the calculator example, a Calculator can have several InputField's, and this relationship is modeled as a child one. But what if I want to be able to navigate from an InputField to its parent Calculator. Do I model this as a child or as a reference? And in either case, how do I specify that InputField.parentCalculator is the reverse of Calculator.inputField?

1 comment
Comment actions Permalink


About 0..n cardinality for references:; it's not because of some model constraints.

About the whole code model: it's not relation model. MPS code is a tree with references between its nodes (AST).

Children and references are completely different. E.g. you can create a child node if you have a parent node, but can't create node if you have a referent node - you first need to create a node as a child of some other (or as a root), and then reference it.

When written before is realized, it should be clear that for navigation to parent Calculator in Calculator example  you don't need to have a reference to the Calculator node - you just need to find parent of your node in the syntax tree with concept=Calculator. It can be done the following way:


or just

inputField.parent (this is worse)


Please sign in to leave a comment.