Referencing property of a concept as an Expression

My concept:

concept Attribute extends Expression implements INamedConcept


properties:
string name;
int average;

children:
Attribute dependsOn;

prettyPrint();

I have an instance of it, named "Age".

Another concept I have is "Strategy". The purpose of it is to define how I calculate some rating based on attributes.

concept Strategy extends Expression implements INamedConcept

children:
Expression rating;

prettyPrint();

In my instance of a Strategy I'd like to be able to define rating like this:

rating = Age.average - Age + dependsOn.average
prettyPrint();

Referencing Age itself is no problem. But referencing properties of a concept itself is another matter, and I don't see how to do that.

Any suggestions?
2 comments
When you want to put something to the right of the dot in baseLanguage, it should implement IOperation.

Create a concept AverageFieldRef implementing IOperation. Add can be child constraint (its parent should be AttributeRef or have AttributeType). Add inference rule, saying

typeof(AverageFieldRef) :==: <int>;
prettyPrint();
As a sample see AsSequenceOperation concept.
0
Evgeny, you are awesome. =)
It took some time for me to understand the idea but in the end, it worked perfectly.
Thanks a lot!
0

Please sign in to leave a comment.