Standard Library

The AutoLang Standard Library provides a set of highly optimized core functionalities. Most of these are auto-imported, meaning they are available globally without any @import statement. Specialized modules (like Math) require explicit importing.


1. Core (Auto-Imported)

These types, functions, and utility classes are available in every file by default.

Primitive Types

Basic types used for fundamental operations. They are marked with @no_extends and cannot be inherited.

  • Int: 64-bit signed integer. Methods: toString()
  • Float: 64-bit floating point number. Methods: toString()
  • Bool: Boolean value (true/false).
  • Void, Null, Any: Special types for VM type-safety.

String

Immutable text sequence. Includes static pseudo-constructors for flexible initialization.

// Static Constructors String() // Empty string String(str: String) // Copy String(str: String, n: Int) // Repeat string n times // Methods func size(): Int // Returns length func toInt(): Int // Parse to Int func toFloat(): Float // Parse to Float func get(index: Int): String // Get char at index func substr(from: Int): String // Substring to end func substr(from: Int, len: Int): String

Collections (Array & Map)

AutoLang provides native, memory-contiguous collections for high-performance data manipulation.

Global Functions

Utilities available globally for debugging and I/O.

FunctionDescription
print(val: Any?)Prints value without a newline.
println(val: Any?)Prints value with a newline.
assert(cond, file, line)Throws an Exception if the condition is false.
getRefCount(val)Debug tool: Returns current reference count of a heap object.

2. Modules (Import Required)

These modules must be imported using @import("path/to/module") at the top of your file.

Math (std/math)

Provides comprehensive mathematical operations. Due to C++ monomorphization, many functions safely overload both Int and Float.

@import("std/math") // Basic Operations Math.abs(v: Int): Int Math.abs(v: Float): Float Math.pow(base: Float, exp: Float): Float Math.fmod(num1: Float, num2: Float): Float // Rounding (Returns Int) Math.round(f: Float): Int Math.floor(f: Float): Int Math.ceil(f: Float): Int Math.trunc(f: Float): Int // Trigonometry (Accepts Int or Float, returns Float) Math.sin(v) Math.cos(v) Math.tan(v) // Random Number Generation Math.random(): Float // 0.0 to 1.0 Math.random(min: Int, max: Int): Int // Random Int within range Math.random(min: Float, max: Float): Float // Random Float within range

Math (std/time)

@import("std/time") Time.now(): Int