Variable Reference

I was reading the MPS documentation on Variable References. (V3.3.5 Sec 24.2.2). I plan on going through the Base Language in order to get the variables functioning as mentioned in the documentation, but I was wondering if any screen casts/ tutorials were ever created that cover this subject also? 

Also any tips/ tricks on setting them up properly are greatly appreciated.




The Calculator tutorial ( covers variable references in the Extending Expressions concept section. Also the languagePatterns sample project that is bundled with MPS cover a sample implementation of the variable-reference pattern.




A small follow up question:

The calculator tutorial creates an inputField and then references it in other parts of the code. Should you always follow that pattern?

If so, when do you use the VariableDeclaration/VariableReference/ Expression pattern used in Base Language? 


Hi Christopher,

I might be misinterpreting your question, but the declaration/reference "pattern" is very common and you will see it implemented in many languages. You frequently need to:

  1. declare things
  2. represent these things in some sort of "expressions" somewhere else in the code

BaseLanguage contains numerous "declarations" (e.g. VariableDeclaration, ParameterDeclaration, MethodDeclaration, etc.), which then can be represented by corresponding references in Expressions. If your language extends BaseLanguage, you can create you can leverage the existing concepts by extending them.




Please sign in to leave a comment.