Skip to content

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.

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 are signed 64-bit values. You can use underscores _ as visual digit separators:

let timeout_ms: int = 5_000
let max_connections: int = 1_000_000

Supported arithmetic operators: +, -, *, /, %. Division between integers performs integer truncation.


Floating-point numbers are 64-bit IEEE-754 values:

let pi: float = 3.14159265359
let temperature: float = -12.4

To convert between int and float, use explicit type conversions:

let n: int = 10
let f: float = float(n)
let back: int = int(f)

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 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)
}