我假设你有这样的定义:
class Foo is (Equatable[Foo box] & Stringable)
var value: I32 = 1
new create(value': I32) => value = value'
fun box eq(other: Foo box): Bool => value == other.value
fun string(): String iso^ => value.string()
primitive Bar
actor Main
fun f(x: (Foo | Bar)): String =>
match x
| Foo(1) => "one"
| Foo(2) => "two"
| let x': Foo => x'.string()
else
"Bar"
end
我认为在这个特殊的情况下这不是太糟糕,但它肯定不是一个真正的解构绑定。Pony只支持这种形式的元组模式
(let first: First, let second: Second)
.