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가 레거시 구문을 마이그레이션하는 빠른 수정 코드 액션을 제공합니다. VS Code / Cursor LSP 코드 액션을 참고하세요.