Types, Built‐in Types, and Literals - CPULL/Dflat GitHub Wiki

Types, Built-in Types, and Literals

Built-in Types

Type Description
i8 i16 i32 i64 i128 i256 Signed integers (sizes not supported in hardware are software-emulated; on very small targets, types wider than 4 bytes may not be available at all)
u8 u16 u32 u64 u128 u256 Unsigned integers
r16 IEEE 754 binary16 (GPU half)
r32 r64 r128 IEEE floats (r128 software-emulated)
dec Fixed-point, 32 + 32 bits
byte Alias of u8
int uns real Target-dependent aliases, to force a specific size for global data or registers; not allowed in dfoot
  • Native size: One compiler option sets the native size used by int / uns / real and by unsuffixed literals. It can force a size below or above the CPU's own.
  • Numbers are not nullable unless declared type?.

3.2 Other Scalars

Type Description
bool true / false
char 32-bit Unicode code point
date instant: 64-bit, ms since 1 Jan 1970 UTC; a null date is represented by the minimum i64 value
time time of day, millisecond resolution; no date, no zone; stored as an i32 (ms since midnight, max 86,399,999); a null time is represented by -1
clock u64 monotonic counter, 0.1 ns, from Clock(); intervals only; Clock() never returns 0; null = 0
lapse difference between two dates or two clocks (Section 3.3)
addr native type holding an address as a number; size from the target definition (64-bit by default, 16 on C64), stored in the most efficient way; comparison and transmute only, arithmetic through pointer methods; cannot be dereferenced; prints as hex in groups of 4 digits separated by spaces; null is 0 (unmapped address). Converting an addr to a pointer results in an unsafe pointer.

3.3 lapse

Used to show an elapsed time span. Signed 64-bit; raw value = value × 8 + code.

Code (bits 2-1-0) Meaning Range
000 null —
010 date lapse, ms ±36 million years
011 clock lapse, 0.1 ns ±3.6 years
100 year lapse beyond ±36M years
111 clock lapse overflow —
  • date − date → date lapse; clock − clock → clock lapse; date − clock → date lapse. date + time → date. date − time → date. time − time → date lapse.
  • Mixed units convert to date lapse, rounding away from zero. Null propagates.
  • Lapses format as numbers in their own unit.

3.4 Composite and Collection Types

Type Description
arr<T> Array: fixed size set at initialization (compile-time or runtime), contiguous; cannot grow or shrink
vec<T> Vector: contiguous and growable (Rust Vec rules)
list<T> Growable, counted B-tree, O(log n) insert/remove
map<K, V> Sorted map (B-tree); alias bmap
hmap<K, V> Hash map
set<T> Sorted set (B-tree); alias bset
hset<T> Hash set
Tuple An ordered set of different types accessed by order and/or by name (must have at least 2 elements)
string UTF-8 text
dfoot Dflat Fast Open Objects Tree, used as serializable tree of objects (similar to JSON)
  • GUID is defined by the EF layer, platform-specific.
  • Lengths and default indexes are u64 everywhere.

Check Collections for the whole description.


Number Literals

Literal Type
123 native signed integer (64 bits on x64 arch, 32 bits on x32 archs, 8 bits on 8 bit archs)
123u u32
123l i64
123ul u64
123s / 123us i16 / u16
123b byte (that is an alias of u8)
1.5 native real
1.5f, 2f r32
6.022e23 native real
0x1F hex; size = smallest type holding the digits (1–2 → 8 bit, 3–4 → 16, 5–8 → 32, 9–16 → 64), zero-filled, widened further if needed; signed; u suffix for unsigned
0b1010 binary, same rules as hex
1_000_000 _ digit separator
  • Suffixes are case-insensitive.
  • Unsuffixed literals take the native size of the target (or the size forced by the native-size compiler option). A value that doesn't fit takes the smallest wider type that does (300 on an 8-bit target → i16).
  • Reals fit by range only (precision loss accepted). The target architecture decides the best native real format (for example r64 on 64-bit, r32 on 32-bit, r16 on 8- and 16-bit, or software emulation where faster).
  • Literals adapt to the declared type; a value that doesn't fit is a compile error.
  • 0x00000000DEADBEEF is a 64-bit value; hex and binary always describe raw bits.
  • A literal transmuted to a pointer is zero-extended to the pointer size: [*i32]0xA0000.

Characters and Strings

  • Chars: 'a'. Strings: "text".
  • Escapes: \n \r \t \\ \' \" \0, code points \u{1F600} (hex) and \#{123} (decimal).
  • An invalid code point in a literal (surrogate, above 0x10FFFF) is a compile error.
  • Interpolated strings: $"Hello {name}, total {x:D,02}"; \{ and \} for literal braces.
  • "" and null are the same: a null string prints as nothing; string is already nullable, so string? is a compile error.

Check Strings for the whole description (layout, small and large strings, toStr()).

⚠️ **GitHub.com Fallback** ⚠️