AutolangDocs

Annotations

Annotations provide compile-time instructions and metadata for classes, functions, and members. In Autolang, annotations begin with the @ symbol.

@override

Explicitly marks a method as overriding a base class definition. If the method does not match any base signature, the compiler issues a compile-time error. You can use @override or the override keyword prefix.

class BaseNotifier { fun notifyUser(userId: String): Bool = false } class PushNotifier extends BaseNotifier { constructor() { super() } @override fun notifyUser(userId: String): Bool { println("Sending push notification to " + userId) return true } } PushNotifier().notifyUser("USR-99")

@no_override

Prevents a method from being overridden in any subclass. This guarantees that critical audit or security logic in a base class remains intact.

class SecureWorkflow { @no_override fun verifyAuditTrail(action: String) { println("Audited action: " + action) } } class CustomWorkflow extends SecureWorkflow { constructor() { super() } // Overriding verifyAuditTrail will trigger a compile-time error }

@native

Declares a capability binding implemented by the host application (in C++ or Node.js). Native functions do not have a body in Autolang scripts. The string argument matches the symbol registered by the host.

// Capability registered by host application class HostCRM { @native("crm_get_customers") fun getCustomers(segment: String): Array<String> @native("crm_charge_account") fun charge(accountId: String, amount: Int): Bool }

@operator

Marks a method as an operator implementation (equivalent to the operator fun keyword prefix). Used to support indexing [], comparison, or arithmetic operators on custom classes.

class StringList(val items: Array<String>) { @operator fun get(i: Int): String = items[i] @operator fun contains(value: String): Bool = value in items } val list = StringList(["alpha", "beta"]) println("First: " + list[0]) // alpha println("Has beta: " + ("beta" in list)) // true

@no_extends & @no_constructor

@no_extends seals a class, preventing any other class from extending it. @no_constructor disallows direct instantiation, which is ideal for creating utility namespaces with static functions.

@no_extends @no_constructor class ValidationUtils { static fun isValidEmail(email: String): Bool { return email.contains("@") && email.contains(".") } } println("Valid: " + ValidationUtils.isValidEmail("admin@enterprise.com"))

@import

Imports standard library modules (std/...) or local relative files (./...) at compile time. Must be placed at the file top-level.

@import("std/math") @import("std/json") @import("./models/customer")