Primitive Types
Every value in Wysna has a concrete, statically checked type. The language provides a focused set of scalar primitives designed for speed and clarity.
Primitive Types Overview
Section titled “Primitive Types Overview”| Type | Description | Representation | Examples |
|---|---|---|---|
int |
Signed 64-bit integer | int64_t in C99 |
0, 42, -15, 1_000_000 |
float |
Double-precision 64-bit IEEE-754 | double in C99 |
0.0, 3.14, -0.005 |
bool |
Boolean truth value | bool in C99 |
true, false |
str |
UTF-8 encoded text buffer | Managed ARC pointer | "hello", "Wysna 🚀" |
unit |
Absence of a meaningful value | void in C99 |
Implicit return of unit |
Integers (int)
Section titled “Integers (int)”Integers are signed 64-bit values. You can use underscores _ as visual digit separators:
let timeout_ms: int = 5_000let max_connections: int = 1_000_000Supported arithmetic operators: +, -, *, /, %. Division between integers performs integer truncation.
Floating-Point (float)
Section titled “Floating-Point (float)”Floating-point numbers are 64-bit IEEE-754 values:
let pi: float = 3.14159265359let temperature: float = -12.4To convert between int and float, use explicit type conversions:
let n: int = 10let f: float = float(n)let back: int = int(f)Strings (str)
Section titled “Strings (str)”Strings in Wysna are immutable UTF-8 buffers managed through Automatic Reference Counting (ARC):
let greeting = "Hello"let subject = "World"let message = greeting + ", " + subject + "!"print(message)print("Length:", len(message))Key string features:
- Inherent value semantics: Passing a string to another function does not create risk of modification by the recipient.
- String slicing and indexing: Substrings and slice operators are validated at runtime for valid UTF-8 boundaries.
- Conversion:
str(42)produces"42".
The unit Type
Section titled “The unit Type”The unit type denotes that an expression or function does not produce a useful value. It is the return type of procedures executed for side effects:
fn log_info(msg: str) -> unit { print("[INFO]: " + msg)}