MPS 2019.1 Help

Other languages

Here we introduce some handy BaseLanguage extensions

Checked dots

Language: jetbrains.mps.baseLanguage.checkedDots

A Checked Dot Expression is an dot expression extended with null checks on the operand.

If the operand is null, the value of the whole checked dot expression becomes null, otherwise it evaluates to the value of corresponding dot expression.

Ways to create a Checked Dot Expression

  • The Make dot expression checked intention

  • Enter "?" after dot, e.g. customer.?address.?street

  • Left transform of operation with "?"

You can transform checked dot expressions to the usual dot expressions using the Make dot expression not checked intention

Overloaded operators

Language: jetbrains.mps.baseLanguage.overloadedOperators

This language provides a way to overload binary operators.

Overloaded operator declarations are stored in an OverloadedOperatorContainer.

If there are several overloaded versions for one operator the most relevant is chosen.

Note that if an overloaded operators' usage is in the other model than its declaration, overloadedOperators language should be added to "languages engaged on generation" of usage's model.

Examples

Overloading plus operator for class Complex:

 

CaptureOverloaded

Also, you can define your own custom operators. Assume we want to create a binary boolean operator for strings, which tells if one string contains another:

CaptureCustomOperator

 

Now, we can simply use this operator:

CaptureIF

Custom constructors

Language: jetbrains.mps.baseLanguage.constructors

Custom constructors provide a simple way to create complex objects. They are stored in a special root node - CustomConstructorsContainer.

Example

Assume we need a faster way to create rectangle.

rectangle

Now, let's create a rectangle:

rectangleusage
Last modified: 5 July 2019