Standard library guide
How to find a module that suits your purpose and read the errors and ownership rules of the function.
Wave Foundation
Find the features you need
The standard library is import with the path std::module::file. Even if the names are similar, functions may return errors in different ways. First read API How to read, then go to the module you need in the following table.
| What I want to do | document | Main import |
|---|---|---|
| String length/comparison/search | string | std::string::len, cmp, find, trim |
| Memory allocation/copy/size | mem | std::mem::alloc, ops, layout |
| List of bytes of varying size | buffer | std::buffer::alloc, read, write |
| Binary read/write | bytes | std::bytes::types, cursor, leb128 |
| File·Descriptor I/O | fs and io | std::fs::file, std::io::fd |
| Path combination/environment settings | path and env | std::path::copy, std::env::environ |
| Time measurement/waiting | time | std::time::duration, clock, sleep |
| Numerical address/name list search | net.resolve | std::net::resolve, resolve_table |
| TCP Connection/Transmission | net.tcp | std::net::tcp, address, error |
| OS Random number | random | std::random::fill |
| Process·OS Boundary | system function | std::process::core, spawn, std::sys |
| Asynchronous task execution | task | std::task |
| Mathematics/Diagnosis Assistant | math and debug | std::math::int, float, std::debug::core |
Example of first use
The program below uses one function from std without downloading a separate package. Save it as main.wave and run it as wavec run main.wave.
import("std::string::len")::{
len
};
fun main() {
println("{}", len("Wave"));
}
The result is 4. To understand the same example step by step, read Strings.
Compatible with compiler std
Confirm the selected path with wavec print std-path. When using std from another checkout, specify the path as wavec --std-root /absolute/path/to/std check main.wave. If the specified path is invalid or incompatible, an error will be displayed.
platform border
Distinguish between computational functions such as string/byte and OS functions such as file/socket. Recognizing a target does not guarantee that all hosts API will be provided. Read the platform entries for Support target and each API together. std::sys is a lower-level interface and portable programs will use the higher-level module first.