Annotation Basics
Annotations are structured metadata markers attached to declarations, starting with @. They provide additional information for elements such as types, functions, and members, which can be read and used at compile time or runtime.
Cangjie allows developers to define their own annotation classes by marking them with @Annotation. A class decorated with @Annotation must provide at least one const init constructor, because annotation instances need to be constructed at compile time. When using annotations, they are attached to declarations using the syntax @AnnotationName[parameters], where parameters must be constant expressions.
For annotations with parameterless constructors, the brackets can be omitted. The code on the right defines a parameterized annotation @Version and a parameterless annotation @Deprecated, applying them to two classes respectively.
abstract, open, or sealed.Try modifying the parameter value of @Version, or add the @Deprecated annotation to ServiceA, and observe the output changes.