Difference between "Used" and "Extended" languages

Hi.

First of all - huge thanks for MPS product.

I have a couple of questions and first - what is a difference between "Used" and "Extended" languages property of a model?

Documentation says:

  • Used language - if module A uses language L, then models inside A can use language L.
  • Extended language - if language L extends language M, then every concept from M can be used inside L as a target of a role or extended concept. Also, all the aspects from language M are available for use and extension from the corresponding aspects in language L.

This is not completely clear for me. What other "uses" a language can have, except mentioned in second item? Could you please give some examples

2 comments
Comment actions Permalink

Hi!

Imagine you have language L and would like to create a "program" using this language. In this case you have to add  L to a list of "used" languages in your model (a sort of "importing" language) and then you will be able to create desired language constructions from language L in this model. Example: you can add "jetbrains.mps.baseLanguage.collections" to a list of used languages in the model and then type something like:

set<string> mySet = new hashset<string>{"str1", "str2", "str3"};

mySet.forEach({~it => System.out.println("Next string in set: " + it); });

On the other side if you are working on a language extension to a language L then you have to add L to a list of Extended Languages of your language (this is a language property, it's not available for the solution).

Example: in MPS calculator tutorial we propose adding jetbrains.mps.baseLanguage to a set of Extended Languages. Then in one of following steps you will be asked to modify OutputField concept in order to contain child element - Expression concept (concept from the base language).

So, there are two different levels of importing language

  • one is important for being able to use corresponding language constructions while working with code (either in your solution or in a language definition model aspects: editor, constraints, generator, typesystem) - "Used Languages" list
  • another is necessary if you'd like to create language extension to an existing one or make use of existing languages in your language (this is a way to import structure model of extended language into your language to allow referencing concepts from another language inside your language structure) - "Extended Languages" list
0
Comment actions Permalink

Thanks a lot, Alex! Very detailed answer.

0

Please sign in to leave a comment.