Skip to content

Annotations

By now, we've already encountered several annotations.

Annotations are a special type of comment. To put it more vividly, annotations are comments for the compiler, influencing how it processes the following statements.

WhirlScript's annotations are divided into two types: statement annotations and declaration annotations.

Statement Annotations

The existing statement annotations include:

AnnotationMeaning
@shThe following statement or block will only be parsed when compiling to sh scripts
@batThe following statement or block will only be parsed when compiling to bat scripts

For the usage of @sh and @bat, see Target Specification.

Declaration Annotations

The existing declaration annotations include:

AnnotationMeaning
@deprecatedThe following declaration has been deprecated.
@noMangleThe name name of following declared variable or function will not be mangled.
@envThe following declared variable is an environment variable. It needs to be declared as a constant.
@editableThe following declared variable is editable, it will be placed at the top of the script after compilation to allow user editing.
@optionalThe following declared variable or function is optional, if it is not used by non-optional parts of the code, it will not be added to the compiled output.
@noScopeThe following declared macro function does not have its own scope.
@expandThe following statement (such as if, for, while) will be expanded during compilation(if possible).

Released under the MIT License.