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
Display
for the type; or - Using the
Log
trait instead ofDisplay
in the format string by using the?
format specifier. For example, the format string$"Hello {x:?}"
will use theLog
trait to formatx
.
Use :? to use Log; e.g. ${myVar:?}.
Generated Code¶
For the C and C++ generators, the default value of
headerOnlyRuntime
has changed fromtrue
tofalse
. 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
logSignalSends
setting has changed fromfalse
totrue
. 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 = false
in theCoco.toml
file.Functions declared as
@noSideEffects
on Coco ports will now be mapped to const member functions in C++. If your models contain a function that is annotated with@noSideEffects
and 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
@noSideEffects
annotation from the function in the Coco model, or ensure that the hand-written subclass code is also const-correct.