///
The Zen standard library (`@std`) provides core functionalities for common programming tasks. These modules are accessible via the `@std` namespace, allowing for modular and expressive imports.
88 views
~88 views from guests
Guest views are estimated from total page views. These include anonymous visitors and users who weren't logged in when they viewed the page.
The Zen standard library (@std) provides core functionalities for common programming tasks. These modules are accessible via the @std namespace, allowing for modular and expressive imports.
@std.io - Input/Output ModuleThe io module provides functions for console input and output.
fn print(message: String): voidfn println(message: String): voidfn eprint(message: String): voidfn eprintln(message: String): voidfn read_line(): Result<String, String>fn read_input(prompt: String): Result<String, String>No types explicitly defined by this module.
@std.math - Mathematical Operations ModuleThe math module provides common mathematical functions.
fn abs(value: f64): f64fn sqrt(value: f64): f64fn pow(base: f64, exp: f64): f64fn sin(angle: f64): f64fn cos(angle: f64): f64fn tan(angle: f64): f64fn log(value: f64): f64fn log10(value: f64): f64fn exp(value: f64): f64fn floor(value: f64): f64fn ceil(value: f64): f64fn round(value: f64): f64fn min(a: f64, b: f64): f64fn max(a: f64, b: f64): f64No types explicitly defined by this module.
@std.string - String Manipulation ModuleThe string module offers utility functions for working with dynamic strings.
fn len(str: String): i64fn concat(a: String, b: String): Stringfn substring(str: String, start: i64, end: i64): Stringfn contains(str: String, pattern: String): boolfn starts_with(str: String, prefix: String): boolfn ends_with(str: String, suffix: String): boolfn replace(str: String, old: String, new: String): Stringfn split(str: String, delimiter: String): Vec<String>fn trim(str: String): Stringfn to_upper(str: String): Stringfn to_lower(str: String): Stringfn format(template: String): Stringfn to_i32(str: String): Option<i32>fn to_i64(str: String): Option<i64>fn to_f32(str: String): Option<f32>fn to_f64(str: String): Option<f64>No types explicitly defined by this module.
@std.vec - Vector/Dynamic Array ModuleThe vec module provides functions and types for dynamic and fixed-size vectors.
fn new(): Vec<T>fn with_capacity(capacity: i64): Vec<T>fn push(vec: Vec<T>, value: T): voidfn pop(vec: Vec<T>): Option<T>fn len(vec: Vec<T>): i64fn is_empty(vec: Vec<T>): boolfn clear(vec: Vec<T>): voidfn get(vec: Vec<T>, index: i64): Option<T>fn insert(vec: Vec<T>, index: i64, value: T): voidfn remove(vec: Vec<T>, index: i64): TVec<T>: A generic vector type.@std.fs - Filesystem ModuleThe fs module offers operations for interacting with the filesystem.
fn read_file(path: String): Result<String, String>fn write_file(path: String, content: String): Result<void, String>fn append_file(path: String, content: String): Result<void, String>fn exists(path: String): boolfn is_file(path: String): boolfn is_directory(path: String): boolfn create_dir(path: String): Result<void, String>fn create_dir_all(path: String): Result<void, String>fn remove_file(path: String): Result<void, String>fn remove_dir(path: String): Result<void, String>fn remove_dir_all(path: String): Result<void, String>fn copy(from: String, to: String): Result<i64, String>fn rename(from: String, to: String): Result<void, String>fn metadata(path: String): Result<FileMetadata, String>fn read_dir(path: String): Result<Vec<String>, String>FileMetadata: A generic type representing file metadata.Path: A generic type representing a filesystem path.@std.net - Network ModuleThe net module provides functionalities for TCP and UDP networking.
fn tcp_listen(port: u16): Result<TcpSocket, Error>fn tcp_accept(listener: Ptr<TcpSocket>): Result<Connection, Error>fn tcp_connect(host: String, port: u16): Result<TcpSocket, Error>fn tcp_send(socket: Ptr<TcpSocket>, data: Ptr<u8>, len: u64): i64fn tcp_recv(socket: Ptr<TcpSocket>, buffer: Ptr<u8>, len: u64): i64fn udp_socket(): Result<UdpSocket, Error>fn udp_bind(socket: Ptr<UdpSocket>, port: u16): i32fn udp_sendto(socket: Ptr<UdpSocket>, data: Ptr<u8>, len: u64, host: String, port: u16): i64fn udp_recvfrom(socket: Ptr<UdpSocket>, buffer: Ptr<u8>, len: u64): RecvResultfn socket_close(fd: i32): i32fn make_sockaddr(host: String, port: u16): SockAddrSockAddr: Represents a socket address.
TcpSocket: A wrapper for a TCP socket file descriptor.
UdpSocket: A wrapper for a UDP socket file descriptor.
Connection: Represents an established network connection.
RecvResult: (Implicitly defined by udp_recvfrom return type) Likely a struct containing bytes received, source address, and port.@std.build - Build System ModuleThe build module provides functions for interacting with the Zen build system.
fn import(module_name: String): Modulefn default_config(): BuildConfigfn compile_file(path: String, config: BuildConfig): BuildResultfn build_project(config: BuildConfig): BuildResultfn compiler_version(): Stringfn target_triple(): Stringfn has_feature(feature: String): boolBuildConfig: A generic type representing build configuration.BuildResult: A generic type representing the result of a build operation.Module: A generic type representing a loaded module.CompilationUnit: A generic type representing a compilation unit.@std.compiler - Compiler Intrinsics ModuleThe compiler module provides low-level intrinsics for direct compiler interaction. Use with caution.
fn inline_c(code: StaticString): voidfn raw_allocate(size: usize): Ptr<u8>fn raw_deallocate(ptr: Ptr<u8>, size: usize): voidfn raw_reallocate(ptr: Ptr<u8>, old_size: usize, new_size: usize): Ptr<u8>fn raw_ptr_offset(ptr: RawPtr<u8>, offset: i64): RawPtr<u8>fn raw_ptr_cast(ptr: RawPtr<u8>): RawPtr<u8>fn call_external(func_ptr: RawPtr<u8>, args: RawPtr<u8>): RawPtr<u8>fn load_library(path: StaticString): RawPtr<u8>fn get_symbol(lib_handle: RawPtr<u8>, symbol_name: StaticString): RawPtr<u8>fn unload_library(lib_handle: RawPtr<u8>): voidNo types explicitly defined by this module.
@std.core - Core Language ModuleThe core module provides fundamental types and compiler intrinsics.
fn size_of(T): u64fn min(a: i64, b: i64): i64fn max(a: i64, b: i64): i64fn abs(n: i64): i64fn clamp(value: i64, min: i64, max: i64): i64fn align_of(T): u64fn type_name(T): Stringfn panic(message: String): voidfn assert(condition: bool): voidtype: A generic meta-type.Any: A generic type representing any type.Result<T, E>: The result type for error handling. (See @std.result for details).Option<T>: The option type for nullable values. (See @std.result for details).Range: A generic type for ranges.@std.result - Result and Option Types ModuleThe result module provides the core Result and Option enum types for robust error handling and nullable values in Zen.
Result<T, E>: Represents a computation that may either succeed or fail.
Ok: T: The success variant, containing a value of type T.Err: E: The failure variant, containing an error value of type E.Option<T>: Represents an optional value; every Option is either Some and contains a value, or None, and does not.
Some: T: The variant containing a value of type T.None: The variant indicating no value.The following functions are available as constructors or patterns, often used directly on the Result or Option type.
Ok(value: T): Creates a Result.Ok variant.Err(error: E): Creates a Result.Err variant.Some(value: T): Creates an Option.Some variant.None: Creates an Option.None variant.