Mic*_*ael 5 continuations scala exception-handling
我从这篇博文中了解到一个单一shift的内容reset是如何具体化的.
reset { 1 + shift {k:Int => Int => k(5)} + 1}
被提到了
val reified = {shiftValue:Int => 1 + shiftValue + 1}; reified (5)
现在我有另一个例子:
reset {
1 + shift(k1:Int => Int => k1(5)} + 1;
2 + shift(k2:Int => Int => k2(6)} + 2
}
它具体到:
val reified ={shifyValue1:Int =>
1 + shiftValue + 1;
2 + shift(k2:Int => Int => k2(6)} + 2
}
reified(5)
我怎样才能进一步把它搞清楚以摆脱第二次shift?
val reified ={shiftValue1:Int =>
1 + shiftValue + 1;
val reified2 = {shiftValue2: Int => 2 + shiftValue + 2};
reified2(6)
}
reified(5)
Run Code Online (Sandbox Code Playgroud)
基本都是一样的改造。
(这里没有安装scala,所以我只在Scheme中测试了这个转换,它的行为应该是相同的,忽略任何类型系统问题。)