Other languages
Here we introduce some handy BaseLanguage extensions.
Checked dots
Language: jetbrains.mps.baseLanguage.checkedDots
A Checked Dot Expression is a 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, for example, 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 operator is used in a model different from its declaration model, the overloadedOperators language should be added to "languages engaged on generation" of that model.
Examples
Overloading plus operator for class Complex:
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:
Now, we can simply use this operator:
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.
Now, let's create a rectangle: