11 lines
472 B
Plaintext
11 lines
472 B
Plaintext
import std::io;
|
|||
|
|
struct serial : attribute { val name: span<u8>; val aliases: span<u8>[2]; }
|
||
|
|
struct weight : attribute { val value: i64 = 1; }
|
||
|
|
const def double(x: i64): i64 { return x * 2; }
|
||
|
|
@serial{ name = "point", aliases = ["p", "pt"] }
|
||
|
|
struct point { @weight{ value = double(21) } var x: i64; @weight var y: i64; }
|
||
|
|
enum axis { @weight x, y }
|
||
|
|
@weight def sum(p: point): i64 { return p.x + p.y; }
|
||
|
|
def main(): void {
|
||
|
|
println($"{sum(point{ 3, 4 })} {axis::y as i64}");
|
||
|
|
}
|