Formats values into strings or prints them to standard output. Supports format markers for numbers, text, characters, and other values.
0 structs · 6 functions · Public API
Functions
print : func(allocator : ^Allocator, fmt : string, args : ...any)
Formats `fmt` with the provided arguments and writes the result to stdout
without appending a trailing newline, using a caller-provided allocator.
Parameters:
allocator : ^Allocator - allocator used for the temporary formatted
string. Must be non-null.
fmt : string - format string containing formatter markers such as
`{v}`, `{d}`, `{b}`, `{f}`, `{s}`, or `{c}`.
args : ...any - values consumed by formatter markers in
left-to-right order.
Returns:
void
Notes:
- The temporary string is freed before this function returns.
- The allocator itself is not destroyed by this overload. print : func(fmt : string, args : ...any)
Formats `fmt` with the provided arguments and writes the result to stdout
without appending a trailing newline.
Parameters:
fmt : string - format string containing formatter markers such as
`{v}`, `{d}`, `{b}`, `{f}`, `{s}`, or `{c}`.
args : ...any - values consumed by formatter markers in left-to-right
order.
Returns:
void
Notes:
- Uses a temporary heap allocator for the formatted string.
- Formatter arguments are type-erased as `any` and resolved at runtime. println : func(allocator : ^Allocator, fmt : string, args : ...any)
Formats `fmt` with the provided arguments and writes the result to stdout
followed by a newline, using a caller-provided allocator.
Parameters:
allocator : ^Allocator - allocator used for the temporary formatted
string. Must be non-null.
fmt : string - format string containing formatter markers such as
`{v}`, `{d}`, `{b}`, `{f}`, `{s}`, or `{c}`.
args : ...any - values consumed by formatter markers in
left-to-right order.
Returns:
void
Notes:
- The temporary string is freed before this function returns.
- The allocator itself is not destroyed by this overload. println : func(fmt : string, args : ...any)
Formats `fmt` with the provided arguments and writes the result to stdout
followed by a newline.
Parameters:
fmt : string - format string containing formatter markers such as
`{v}`, `{d}`, `{b}`, `{f}`, `{s}`, or `{c}`.
args : ...any - values consumed by formatter markers in left-to-right
order.
Returns:
void
Notes:
- Uses a temporary heap allocator for the formatted string.
- Prefer `print` when the caller wants to control line endings. println : func()
Writes a newline to stdout.
Parameters:
None.
Returns:
void
Notes:
- Does not create a temporary formatted string or allocator.
format_string : func(allocator : ^Allocator, fmt : string, args : ...any) -> string
Builds an owned string by replacing formatter markers in `fmt` with the
corresponding values from `args`.
Parameters:
allocator : ^Allocator - allocator used to allocate the returned string.
Must be non-null.
fmt : string - format string containing formatter markers such as
`{v}`, `{d}`, `{b}`, `{f}`, `{s}`, or `{c}`.
args : ...any - values consumed by formatter markers in left-to-right
order.
Returns:
string - formatted string allocated with `allocator`, or an empty string
when `allocator` is null or `fmt` is empty.
Notes:
- The caller owns the returned string and must release it with
`free_string` using the same allocator.
- `{v}` uses the default representation for the argument's runtime type.