Skip to content

Constants

Constants

Thagore supports immutable top-level constants with explicit type annotations.

Declaring a constant

const LIMIT: i32 = 10

Constants are lowered at compile time and behave like immutable module-level bindings.

Builtin shipped constants

The current repository ships these constants in std.math:

NameTypeValue
PIf643.141592653589793
Ef642.718281828459045
INFf641.0 / 0.0
MAX_I32i322147483647
MIN_I32i32-2147483648

Using constants

import std.math as math
func main() -> i32:
if (math.PI > 3.14 and math.PI < 3.15):
return 0
return 1
import std.math as math
func main() -> i32:
if (math.E > 2.71):
return 0
return 1
import std.math as math
func main() -> i32:
if (math.MAX_I32 == 2147483647):
return 0
return 1