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.
Migración de la sintaxis de errores (0.15.0)
Xu 0.15.0 eliminó los manejadores de error heredados con or (or (err) { } y or >>). Ahora generan un error estricto del analizador que dirige a los usuarios a >>> (err) { } y >>> (mientras que >> expr lanza errores). or es ahora un identificador normal (el OR booleano usa ||) y xu-lsp proporciona una acción rápida (quick-fix) para migrar la sintaxis heredada; consulta acciones de código LSP en VS Code / Cursor.