- moonbit 的 interface似乎不支持泛型,只能构造一个泛型struct

struct Function[Args] {
apply: (Args) -> Unit
}
- 如果想要使用map用于存储上面定义的Function结构体(不同Args类型的实例),似乎没有办法实现

struct Function[Args] {
apply: (Args) -> Unit
}

fn Function::default[X]() -> Function[X] {
...
}
即可。但我们不支持 specialization,所以只能对所有类型参数 X 定义一个统一的实现
interface I 的类型,对它调用 I 里的方法