Repository navigation
EN Cookbook
Arena Agent edited this page Sep 18, 2026
·
2 revisions
func average(a: float, b: float) -> float {
return (a + b) / 2.0;
}
say(average(10.0, 14.0));
Use annotations at public boundaries and in code where they clarify intent. Leave local expressions inferred when the result is obvious.
struct Point { x: float, y: float }
impl Point {
func translate(&mut self, dx: float, dy: float) {
self.x = self.x + dx;
self.y = self.y + dy;
}
}
&mut self communicates that the method changes the receiver. این annotation فقط syntax نیست؛ قرارداد تغییرپذیری API را هم مشخص میکند.
func report(values) {
for value in values {
say("value = ${value}");
}
}
report([3, 1, 4]);
Keep input parsing, transformation, and output in separate functions. This makes plix test suites smaller and compiler diagnostics easier to localize.
- Run
plix checkbefore investigating runtime output. - Reduce a failing program to the smallest
.pxfile. - Test the reduced case with both
runandbuild. - If a borrow error appears, identify which call needs ownership and which only needs a borrow.
- Do not use the native path as a substitute for checking: native compilation assumes the program passes the language checks.
Learning path: ← Architecture · Standard Library →
- Getting Started
- Installation
- Language Reference
- Types and Ownership
- Structs and Traits
- Modules and Projects
- Standard Library
- Error Guide
- Runtime Model
- Architecture
- Compiler Development
- Testing and Tooling
- Cookbook
- Python FFI
- FAQ
- Contributing