Magic Constants
Autolang provides compile-time constants resolved directly by the compiler. Because they are substituted during compilation, they carry zero runtime overhead and provide deterministic audit and diagnostic data.
Available Constants
| Constant | Type | Description |
|---|---|---|
| __LINE__ | Int | The current line number in the source file. |
| __FILE__ | String | The name of the current source file being compiled. |
| __FUNC__ | String | The name of the enclosing function, or an empty string at file top-level. |
| __CLASS__ | String | The name of the enclosing class, or an empty string outside a class. |
Audit Logging & Diagnostics
Combine magic constants with string interpolation to emit structured diagnostics that identify the exact source location of a business workflow step.
class PaymentAuditor {
fun recordStep(stepName: String) {
println("[${__FILE__}:${__LINE__}] ${__CLASS__}.${__FUNC__}() -> Step: " + stepName)
}
}
val auditor = PaymentAuditor()
auditor.recordStep("AUTHORIZE_SETTLEMENT")Assertions with Location Metadata
Magic constants pair with the global assert() function to produce actionable failure reports when invariant conditions fail.
fun validateTransactionLimit(amount: Int): Bool {
assert(amount > 0, "Invalid amount at ${__FILE__}:${__LINE__}")
return amount <= 50000
}
println("Limit checked: " + validateTransactionLimit(1500))