Migrating to Coco Standard 2024¶
The Coco Language standard 2024 includes several features that have required backwards-incompatible changes to be made to the language and also the generated code. These will require users to manually alter their code in order to use their existing models with the new language standard.
Coco¶
Format strings now use the :Display trait by default instead of the Log trait.
For example, with standard = "1.2", a format string such as $"Hello {x}" would format x using the Log trait. With
Coco 2024, the Display trait is used instead.
To migrate, upgrade to Coco 2024 and look at the errors in your project. Any errors relating to missing instances of the
Display trait can be solved either by:
- Implementing
Displayfor the type; or - Using the
Logtrait instead ofDisplayin the format string by using the?format specifier. For example, the format string$"Hello {x:?}"will use theLogtrait to formatx.
Use :? to use Log; e.g. ${myVar:?}.
Generated Code¶
For the C and C++ generators, the default value of
headerOnlyRuntimehas changed fromtruetofalse. This means that, by default, the generated code will no longer generate the runtime code in a single header file, and instead will generate it as a separate header and source file.For the C, C# and C++ generators, the default value of
logSignalSendssetting has changed fromfalsetotrue. This means that sends of signals will now be logged by default.The previous behaviour can be restored by setting, for example,
generator.cpp.logSignalSends = falsein theCoco.tomlfile.Functions declared as
@noSideEffectson Coco ports will now be mapped to const member functions in C++. If your models contain a function that is annotated with@noSideEffectsand is implemented by an external component, the hand-written subclass code might also require changes to ensure const-correctness.To fix this, either remove the
@noSideEffectsannotation from the function in the Coco model, or ensure that the hand-written subclass code is also const-correct.