Intrinsics are functions and values that the CLS runtime makes available in every program without anyDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/elfrask/cls/llms.txt
Use this file to discover all available pages before exploring further.
import statement. They are registered directly into the global environment by the interpreter at startup — some by Intrinsics::desktop_defaults (the node-supplied layer: print, input) and the rest by register_core_intrinsics (always present regardless of the node). If you are embedding CLS with Intrinsics::empty(), the node-level intrinsics (print, input) will not be registered at all — referencing them in a script will throw an undefined-variable error. The core set (toString, int, float, bool, str, len, type, now, exit, sleep, throw) is always present. Command-line arguments (args) are passed as the String[] parameter to main() — they are not a standalone global variable.
Reference
| Function / Value | Signature | Description | Notes |
|---|---|---|---|
print | print(...values) | Prints all arguments to stdout, separated by spaces | Calls __toString on class instances |
input | input() -> String | Reads one line from stdin | Node-provided; not available when using Intrinsics::empty() |
toString | toString(val) -> String | Returns string representation of val | Calls __toString on class instances |
int | int(val) -> int | Converts val to integer | Parses strings; truncates floats; calls __int |
float | float(val) -> float | Converts val to float | Parses strings; widens ints; calls __float |
bool | bool(val) -> bool | Converts val to boolean (truthiness) | Calls __bool on class instances |
str | str(val) -> String | Alias for toString | Same behaviour |
len | len(val) -> int | Length of an array, tuple, record, string, or object with __len | Errors on other types |
type | type(val) -> String | Returns the runtime type name as a string | Calls __type if defined on instance |
now | now() -> int | Returns the current Unix timestamp in milliseconds | Uses SystemTime::now() |
exit | exit(code) | Terminates the process with the given exit code | Calls std::process::exit |
sleep | sleep(ms) | Pauses execution for ms milliseconds (blocking) | For async delays prefer async.delay(ms) |
throw | throw(msg) | Raises a RuntimeError with the given message | Aborts current execution; caught by try/catch |
args | args: String[] | Array of command-line argument strings — passed as the parameter to main() | Empty array when no CLI args are given |
Examples
print
input
toString and str
int, float, bool
len
type
now
exit
sleep
throw
args
Magic Method Integration
Several intrinsics are intercepted by the interpreter when called on class instances, delegating to special magic methods defined on the class. This lets your classes integrate seamlessly with the global built-ins.| Intrinsic | Magic Method | Signature | Behaviour |
|---|---|---|---|
print, toString, str | __toString | () -> String | Called to produce the string representation |
int | __int | () -> int | Called to produce an integer conversion |
float | __float | () -> float | Called to produce a float conversion |
bool | __bool | () -> bool | Called to produce a boolean conversion |
len | __len | () -> int | Called to return the logical length |
type | __type | () -> String | Called to return a custom type name string |
Example — all magic methods on one class
If a class does not define
__toString, print and toString fall back to the default Value::to_string() representation, which shows the underlying runtime debug format.