Constraints inheritance and composition

In my JMeter DSL (http://forum.jetbrains.com/message/Meta-Programming-System-4911-2) I want to have some constraints to prevent nodes being created in the non-proper positions.

I think the best way to express the constraints is to use "traits".
For instance: "a Sampler can't have another Sampler as a child". "Configuration can't have another configuration as a child". "Sampler should have ThreadGroup ancestor".

I thought I could factor out those kind of constraints into ConceptInterfaces and add those interfaces to the "implements" list as required.

My "constraint concept interfaces" are IRequiresThreadGroup (parentNode.ancestor<concept = ThreadGroup, +>.isNotNull), ILeafSampler (parentNode.ancestor<concept = ILeafSampler, +>.isNull), etc. In the actual concept I just implement the required interfaces.

However, this does not work since MPS uses just the very first constraint method it sees when it walks the hierarchy.

Is that intentional?
What is the MPS way of composing constraints?
Should I file an issue for that?
2 comments
Hi Vladimir,
yes, the current design uses the most-specific constraint definition only. You'll have to create composable constraints yourself, perhaps using (static) behaviour methods or plain Java classes.
Would you mind submitting this case including the motivation as a feature request to our tracker, please?

Vaclav
0

Please sign in to leave a comment.