Annotations
Annotations are currently an experimental work-in-progress language feature. Their design may change in a backward incompatible manner. |
Annotations can be added to elements of a CIF specification, to annotate them with extra information. Annotations are a form of structured data, and the CIF type checker checks their validity. Tools that take CIF specifications as input can process the annotations that are attached to elements of the specification, and use the supplied information.
Annotations differ from comments. Comments can also be used to add additional information to a specification. However, comments are completely free form, as you can write anything in them. They can even be used to (temporarily) comment out some parts of the specification. Furthermore, comments are purely for the benefit of the modeler. They are never interpreted by a tool.
Annotations have two main purposes:
Annotations allow for extensibility, as anyone can add annotations, whether it is general purpose, company-specific, or even for private use.
Annotations allow to test out language extensions before fully integrating them into the language.
Currently, annotations are only supported for input variables, but this will be extended to other elements of specifications in the future.
The following annotations are bundled with CIF:
Category | Annotation |
---|---|
|
Documentation annotations
Documentation can be added to input variables:
@doc($text = "The lower limit sensor of the elevator.")
input bool ElevatorDownSensor;
This documentation can then be used by CIF tools in various ways. For instance, the CIF code generator includes this documentation in the generated code. For the above example, it may generate the following Java code:
/**
* Input variable "ElevatorDownSensor".
*
* <p>
* The lower limit sensor of the elevator.
* </p>
*/
public boolean ElevatorDownSensor;