再帰関係のABC

再帰関係のABCを淡々と貼るよ。callerとcalleeは意図的に無視してるよ。あと、Yコンビネータとか。

普通の再帰

function forever(){
	forever();
}
var undefined():*       /* disp_id 0*/
{
  // local_count=1 max_scope=0 max_stack=1 code_len=7
  0         findpropstrict      forever
  2         callproperty        forever (0)
  5         pop
  6         returnvoid
}

末尾再帰の最適化はしないのか。読みやすいからいいんだけど
だいたい1000回でオーバーフローする。

相互再帰

function f(){ g(); }
function g(){ f(); }
// f
var undefined():*       /* disp_id 0*/
{
  // local_count=1 max_scope=0 max_stack=1 code_len=7
  0         findpropstrict      g
  2         callproperty        g (0)
  5         pop
  6         returnvoid
}

// g
var undefined():*       /* disp_id 0*/
{
  // local_count=1 max_scope=0 max_stack=1 code_len=7
  0         findpropstrict      f
  2         callproperty        f (0)
  5         pop
  6         returnvoid
}

無名関数による再帰

無名関数による再帰。これ、Javascriptではできない、って話なかった?
ABC的には普通の再帰と同じ。

var fact = function(){
	fact();
};
var undefined():*       /* disp_id 0*/
{
  // local_count=1 max_scope=0 max_stack=1 code_len=7
  0         findpropstrict      fact
  2         callproperty        fact (0)
  5         pop
  6         returnvoid
}