Light Dark

Functions

capture-stderr core

fn ()

Redirect stderr to a capture handle for later retrieval.

Example

handle capture-stderr()
eprintln("error message")
content get-captured-content(handle)
release(handle)

capture-stdout core

fn ()

Redirect stdout to a capture handle for later retrieval.

Example

handle capture-stdout()
println("captured text")
content get-captured-content(handle)
release(handle)
// content = "captured text\n"

clear-captured-content core

fn (handle)

Clear buffered output for a capture handle.

Example

handle capture-stdout()
println("first")
clear-captured-content(handle)
println("second")
content get-captured-content(handle)
// content = "second\n" ("first" was cleared)

eprint core

fn (message: Any): Str

Write message to stderr and return its string form.

Example

eprint("Warning: ")  // Outputs to stderr (no newline)

eprintln core

fn (message: Any): Str

Write message to stderr with a trailing newline and return its string form.

Example

eprintln("Error: something went wrong")  // Outputs to stderr

get-captured-content core

fn (handle)

Get buffered output from a capture handle.

Example

handle capture-stdout()
println("test output")
content get-captured-content(handle)
// content = "test output\n"

print core

fn (message: Any): Str

Write message to stdout and return its string form.

Example

print("Hello")    // Outputs: Hello (no newline)
print(42)         // Outputs: 42

println core

fn (message: Any): Str

Write message to stdout with a trailing newline and return its string form.

Example

println("Hello, World!")  // Outputs: Hello, World!\n
println({"a": 1})         // Outputs: {"a": 1}\n

discard

fn (handle)

Discard a capture handle without printing captured content.

Example

handle capture-stdout()
println("this will be discarded")
discard(handle)  // Content is lost, not printed

release

fn (handle)

Release a capture handle and restore the original stream.

Example

handle capture-stdout()
// ... do work ...
release(handle)  // Restores normal stdout