Language Guide / Types & Annotations

Types & Annotations

Dynamic runtime values, strict operations, missing, and compile-time type annotations with union types.

Core Value Types

TypeLiterals / ExamplesNotes
int42, 0, -7Exact signed integer
float1.5, 1e-3Finite IEEE-754 floating-point
string"hello\n"UTF-8 immutable text
booltrue, falseStrict boolean (no truthy ints)
missingmissingExplicit null / absent value
list[1, 2, 3]Ordered immutable sequence
record{name: "dlang"}Immutable key-value record

Optional Static Type Annotations

Variables, function parameters, and return types accept optional type annotations validated by dlang check and the compiler frontend.

typed.dl
count: int = 0
items: list<int> = [1, 2, 3]

fn find_user(id: int) -> string | missing
    if id == 1
        return "Ada"
    end
    return missing
end
Strict Operations
Dlang does not silently coerce types in + or ==. Use to_string(x), to_int(x), to_float(x), or to_bool(x) for explicit conversions.