Constants
Constants
Thagore supports immutable top-level constants with explicit type annotations.
Declaring a constant
const LIMIT: i32 = 10Constants are lowered at compile time and behave like immutable module-level bindings.
Builtin shipped constants
The current repository ships these constants in std.math:
| Name | Type | Value |
|---|---|---|
PI | f64 | 3.141592653589793 |
E | f64 | 2.718281828459045 |
INF | f64 | 1.0 / 0.0 |
MAX_I32 | i32 | 2147483647 |
MIN_I32 | i32 | -2147483648 |
Using constants
import std.math as math
func main() -> i32: if (math.PI > 3.14 and math.PI < 3.15): return 0 return 1import std.math as math
func main() -> i32: if (math.E > 2.71): return 0 return 1import std.math as math
func main() -> i32: if (math.MAX_I32 == 2147483647): return 0 return 1