Other Built-In Functions

Built-in functions for output, debugging, and logging

Built-in functions that are always available without imports.


Output

print

fn print(message: String)

Prints a message to stdout.

Always outputs to stdout and cannot be compiled away.

Parameters

  • message — The string to print

Example

print("Hello, world!")
print('Player health: {health}')

Debugging

assert

fn assert(condition: Bool, message: String)

Asserts that a condition is true. If the condition is false, the program terminates with an error.

Can be compiled away in release builds for performance.

Parameters

  • condition — The condition to check
  • message — Optional message to display if the assertion fails

Example

assert(index < array.len(), "Index out of bounds")

panic

fn panic(message: String)

Terminates the program immediately with an error message.

Cannot be compiled away — always included in all builds.

Parameters

  • message — The error message to display

Example

if health > 100 {
    panic('health value is not correct {health}')
}

Logging

All logging functions can be compiled away in release builds.

warn

fn warn(message: String)

Logs a warning message.

Example

warn("Performance degradation detected")

notice

fn notice(message: String)

Logs a notice message. It is not a warning, not something that went wrong, but something you should notice.

Example

notice("network latency is high")

info

fn info(message: String)

Logs an informational message.

Example

info('Loading level: {level_name}')

debug

fn debug(message: String)

Logs a debug message.

Example

debug('Player position: ({x}, {y})')

trace

fn trace(message: String)

Logs a detailed trace message.

Example

trace("Entering update_physics() function")