Skip to main content

Standard Library (std)

This section explains the practical usage of the Wave standard library.

Module

Usage Principles

  • In high-level code, use std::*.
  • OS-dependent features are hidden behind std::sys::*.
  • Use std::libc only when C compatibility is needed.

Error Handling Convention

Many functions follow this convention.

  • >= 0: Success
  • < 0: Failure (-errno or module-specific error code)

Example:

import("std::env::environ");

fun main() {
var raw: array<u8, 64>;
var n: i64 = env_get("HOME", &raw[0], 64);

if (n < 0) {
// Handle error
return;
}

// raw contains a NUL-terminated string
}