XU XUv0.16.0

Functions

fn add(a int, b int) int {
    << a + b
}

fn (c $&Counter) inc() {
    c.n += 1
}

Variadic is trailing name <-> T, seen as []T in the body. Errors are not extra return values; they use >> + >>> (err).

In expressions << / >> remain shifts; as statements they return/throw; >>> propagates & handles errors. Boolean or is ||. Division by zero and out-of-bounds index fail loud.

Generic Type Parameters

Declare type parameters after # in the function name; calls are monomorphized from their arguments. 0.9.4 removes the four-type-parameter limit on generic declarations:

fn fifth#A,B,C,D,E(a A, b B, c C, d D, e E) E {
    << e
}

// fifth(1, true, 3.0, "four", 5) returns 5

See the generics tutorial for method-set constraints and dynamic boxes.

エラー構文の移行(0.15.0)

Xu 0.15.0 では旧 or エラーハンドラ(or (err) { } および or >>)が削除され、パーサのハードエラーとして >>> (err) { } および >>> の使用が案内されるようになりました(エラー送出は >> expr)。or は通常の識別子として解放され(論理 OR は ||)、xu-lsp は旧構文を移行するためのクイックフィックス Code Action を提供します。詳細は VS Code / Cursor LSP コードアクションを参照してください。