Print¶
Console output utilities.
Module: Std::Io
Summary¶
import Std::Io::{ Print, PrintLine };
import Std::Format;
func Main() -> int {
let score: int32 = 9001;
let name = String::From("Alex");
PrintLine("Player: {}", name);
PrintLine("Score: {}", score);
Print("Status: ");
PrintLine("active");
return 0;
}
Description¶
The Std::Io module provides console output functionality for strings, primitive types, and formatted text.
All supported primitive types can be printed directly. Internally, values are converted to strings before being written to the console.
The module supports:
- Primitive numeric types
- Boolean types
- Character types
- Strings
- Formatted output using
Display
Print¶
Writes a value to standard output without appending a newline.
Overloads¶
Primitive Types¶
Print(value: int8)
Print(value: int16)
Print(value: int32)
Print(value: int64)
Print(value: int)
Print(value: uint8)
Print(value: uint16)
Print(value: uint32)
Print(value: uint64)
Print(value: float32)
Print(value: float64)
Print(value: bool8)
Print(value: bool16)
Print(value: bool32)
Print(value: bool)
Print(value: char8)
Print(value: char16)
Print(value: char32)
Print(value: char)
Strings¶
Print(string: *const char8, length: uint)
Print(string: *const char16, length: uint)
Print(string: char8[])
Print(string: char16[])
Print(string: String)
Formatted Output¶
Formats the arguments using Format() and writes the result to standard output.
Example¶
Output:
PrintLine¶
Writes a value to standard output and appends a newline.
Overloads¶
Newline Only¶
Writes a line terminator.
Primitive Types¶
PrintLine(value: int8)
PrintLine(value: int16)
PrintLine(value: int32)
PrintLine(value: int64)
PrintLine(value: int)
PrintLine(value: uint8)
PrintLine(value: uint16)
PrintLine(value: uint32)
PrintLine(value: uint64)
PrintLine(value: float32)
PrintLine(value: float64)
PrintLine(value: bool8)
PrintLine(value: bool16)
PrintLine(value: bool32)
PrintLine(value: bool)
PrintLine(value: char8)
PrintLine(value: char16)
PrintLine(value: char32)
PrintLine(value: char)
Strings¶
PrintLine(string: *const char8, length: uint)
PrintLine(string: *const char16, length: uint)
PrintLine(string: char8[])
PrintLine(string: char16[])
PrintLine(string: String)
Formatted Output¶
Formats the arguments using Format(), writes the result, and appends a newline.
Example¶
Output:
Notes¶
- Primitive values are converted to strings automatically.
- Formatted output uses
Format(). - Values supplied to formatted output must implement
Display. Print()does not append a newline.PrintLine()always appends a newline.
Platform Notes¶
Linux / BSD / Illumos¶
- UTF-8 text is written directly to standard output via the
writesyscall. - Linux:
SYS_WRITE = 1(negative errno). - BSD / Illumos:
SYS_WRITE = 4(positive errno).
Windows¶
- UTF-8 text is converted to UTF-16 before being written to the console.
- UTF-16 output is written using the Windows console API.
Output Length Limit¶
Strings longer than 4096 characters currently cause a fatal error when printed. Attempting to print a longer UTF-8 string will terminate the program with:
This limitation applies to:
when the underlying string exceeds 4096 characters.