我想通过在遇到StackOverflowError时返回一个thunk来实现java中的trampoline.是否有任何关于StackOverflowError的保证,比如,如果在StackOverflowError之后我唯一要做的就是在堆上创建对象并从函数返回,我会没事的?
如果上面的内容听起来很模糊,我在延续传递方式中以尾递归的方式添加了一些用于计算偶数/奇数的代码,每当堆栈流过时返回一个延迟的thunk.代码在我的机器上运行,但Java是否保证它始终有效?
public class CPS {
public static class Thunk {
final Object r;
final Continuation c;
final boolean isDelayed;
public Object force() {
Thunk t = this;
while (t.isDelayed)
t = t.compute();
return t.r;
}
public Thunk compute() {
return this;
}
public Thunk(Object answer) {
isDelayed = false;
r = answer;
c = null;
}
public Thunk(Object intermediate, Continuation cont) {
r = intermediate;
c = cont;
isDelayed = true;
}
}
public static class Continuation {
public …Run Code Online (Sandbox Code Playgroud) 首先,我之前已经看到了这个问题的答案,但它被许多"答案"所掩盖,这些"答案"没有正确回答我的问题,我再也找不到了.
所以这就是:我如何将Git恢复到历史记录中的先前版本,以便它成为我当前历史记录中的新提交?
基本上,这是我想用版本控制系统做的最基本的事情.简单地执行重置不起作用,因为它抛弃了我的历史记录,简单的恢复也不起作用,因为有时它会给我错误消息(我想要做的事情应该是没有任何错误消息的).
编辑:
如果我只是做了git revert这个错误发生:
git revert HEAD~1
error: could not revert f1b44e3... Towards translating API to kernel.
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
Run Code Online (Sandbox Code Playgroud) 我如何制定
[NSClassFromString(classname) myMethod:param1 more:param2];
Run Code Online (Sandbox Code Playgroud)
这样编译器不会发出警告说+ myMethod可能没有实现?