21 lines
374 B
Plaintext
21 lines
374 B
Plaintext
// A closure stored in a struct field receives sub-32-bit enum args
|
|
// with the right tag, same as direct or protocol-dispatched calls.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
Fmt :: enum { a; b; }
|
|
|
|
Ctx :: struct {
|
|
on: Closure(Fmt) -> void;
|
|
}
|
|
|
|
main :: () -> s32 {
|
|
c : Ctx = .{ on = (f: Fmt) => {
|
|
n : s64 = xx f;
|
|
print("cl f = {}\n", n);
|
|
}};
|
|
c.on(.b);
|
|
c.on(.a);
|
|
0;
|
|
}
|