【发布时间】:2015-02-13 15:36:11
【问题描述】:
我正在尝试使用 &T 概念在 Rascal 中使用泛型类型。不过,有些事情我觉得有点奇怪。我不清楚为什么以下内容不起作用:
private tuple[str,int] synthesise_p(Fancy::AST::Exp exp, int count) {
switch (exp) {
case &T n(&T e0, &T e1, &T e2): {
println("e0: <e0> typeOf(e0): <typeOf(e0)>\ne1: <e1> typeOf(e1): <typeOf(e1)>\ne2: <e2> typeOf(e2): <typeOf(e2)>\n");
for (ty <- e0) {
println("ty: <ty>");
}
}
}
}
当我打印e0、e1 和e2 时:
e0: ["x"] typeOf(e0): list(str()
e1: [nat(1),nat(2)] typeOf(e1): list(adt("Exp",[]))
e2: nat(3) typeOf(e2): adt("Exp",[])
出现以下错误:
|rascal://Synth::Synthesiser|(2291,2,<81,23>,<81,25>): value is not enumerable
?[Advice](http://tutor.rascal-mpl.org/Errors/Static/NotEnumerable/NotEnumerable.html)
我真正想做的是能够遍历e0 和e1 并提取这些列表中每个元素的类型。
我错过了什么/做错了什么?
谢谢!
【问题讨论】: