Overview
Overview
std is the PekoScript standard library. It is a normal package, but it is
installed once at the global Peko root when the toolchain is set up, so projects
never list it as a dependency and its version tracks the installed compiler.
Modules are reached through the std:: prefix once imported:
import std::fs;
let text: string? = fs::read_file(path)Several modules are already imported for you. That list is on the next page and
is worth reading before anything else, because it decides whether a name is
spelled Array, json::parse, or needs an import first.
What is here
| Module | Purpose |
|---|---|
core |
The object model, the value types, and the traits behind the operators. |
collections |
Arrays, maps, ordered maps, string building, pairs. |
io |
Console and file-descriptor input and output. |
fs |
Files, directories, handles, buffered reads and writes. |
json |
A JSON value tree, a parser, and the JSON serializer. |
xml |
An element tree with attributes, children, and rendering. |
crypto |
Hashing, AEAD, signatures, password hashing, encoding. |
sockets |
TCP, HTTP and HTTPS, WebSocket clients and servers. |
threads |
Threads, mutexes, channels, futures, cancellation. |
process |
Spawning child processes and streaming their output. |
random |
Fast non-cryptographic random numbers. |
lexer |
A small general tokenizer. |
runtime |
Allocation and the garbage collector boundary. |
bundle |
Compile-time project metadata. |
Two habits worth forming early
Most calls that can fail return an optional rather than a sentinel, so the empty case is impossible to ignore:
let content: string? = fs::read_file(path)
if !content.is_value() {
return None
}But not all of them. A handful return a sentinel value instead, and those are the ones that cause bugs, because nothing forces you to check. The Optionals and sentinels page lists every one.