Let’s say you are implementing a language for computations with physical units. Your language supports defining basic units (meters or seconds) and combining them into complex units (meters per second).

You would like to provide a “standard library” with all the SI units, and make them available without the user having to import anything. MPS supports this use case via accessory models. These models are specified in language properties and are then made available to any model that uses the language, without requiring any additional imports.

We can thus create a model with SI units, specify it as the accessory model of the units language, and publish the language. All users of our language will automatically see SI units without having to add any extra dependency or import anything.

What if we receive the units language as a library and want to add imperial units (feet and gallons)? We cannot modify the original language if it’s part of a library, yet we have to modify it to add another accessory model. How do we solve this?

A solution is to define another language and specify the imperial units model as its accessory model. We then include this new language into our devkit1 along with the original language, and it will be automatically available in the user models, bringing the imperial units accessory model with it.


  1. I consider defining a devkit for your users a best practice↩︎