5.1.25. Annotations and Options

This tutorial covers function and struct annotations, and compiler options that control lint, safety, and optimization.

5.1.25.1. Function annotations

Annotations are placed in [ ] before the function definition:

[export]
def main { ... }

[sideeffects]
def log(msg : string) { print(msg) }

[unused_argument(y)]
def use_only_x(x, y : int) : int { return x * 2 }

Common function annotations:

  • [export] — callable from host application

  • [sideeffects] — has side effects, won’t be eliminated

  • [init] — runs at context initialization

  • [finalize] — runs at context shutdown

  • [deprecated(message="...")] — produces warning on use

  • [unused_argument(x)] — suppress unused arg lint

  • [unsafe_operation] — calling requires unsafe block

  • [no_aot] — disable AOT for this function

  • [jit] — request JIT compilation

5.1.25.2. Combining annotations

Separate multiple annotations with commas:

[export, sideeffects]
def annotated_func() { ... }

5.1.25.3. Struct annotations

  • [safe_when_uninitialized] — zero-filled memory is valid

  • [cpp_layout] — C++ struct alignment

  • [persistent] — survives context reset

5.1.25.4. Private functions

Use the private keyword:

def private helper() : string {
    return "module-private"
}

5.1.25.5. Compiler options

Set at the top of a file:

options gen2
options no_unused_function_arguments
options stack = 32768

Key options:

Option

Description

gen2

Enable gen2 syntax

no_unused_function_arguments

Unused args become errors

strict_smart_pointers

Strict smart pointer checks (default: on)

no_global_variables

Disallow module-level globals

unsafe_table_lookup

tab[key] requires unsafe (default: on)

stack = N

Stack size in bytes

no_aot

Disable AOT for module

lint

Enable/disable all lint checks

no_deprecated

Deprecated usage becomes error

See also

Annotations, Options in the language reference.

Full source: tutorials/language/25_annotations_and_options.das

Next tutorial: Contracts