作者BBSealion (海狮)
看板EE_DSnP
标题Re: [情报] 关於 dofile recursion depth 超过 102 …
时间Sun Nov 14 22:27:59 2010
顺带问个问题
作业中说不能让recursive超过1024
// (3) If a dofile xx contains a line "dofile xx" calling itself,
// where xx may or may not exist... (recursive dofiles)
// (Let the max recursion depth = 1024)
//
这是限制在自己recursive自己的情况下才能做这个例外行动吗 ?
(例如do1 file 中又去do do1)
还是说只要连去往下探1024件 dofile就可以自动要求执行中断了
(例如do1 file中有do do2,do2 file中有do do3 do3 file中又有 do do1...)
或者说不管是不是陷入无限loop的情况
我只要判断(dofile 被 call out)的次数(或说size)到达1024就中断?
---
感觉如果要只判断自我recursive的状况而其他不行的话有点麻烦...
而且似乎直觉上不会有人在这种状况以外,还可以call out 1024次 dofile
所以管他怎样,只要call out 1024次就自动停止似乎还算合理的举动(?)
而且也很难测试,因为往往再超过1024就会crash
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.168.225.47
※ 编辑: BBSealion 来自: 218.168.225.47 (11/14 22:44)
1F:推 ric2k1:For recursive dofiles, you may need to use a stack to 11/14 22:50
2F:→ ric2k1:record the calling dofiles. Therefore, you can just 11/14 22:50
3F:→ ric2k1:test the size of the stack as the recursion depth. 11/14 22:51
4F:→ BBSealion:OK 那就没问题了 谢谢 11/14 22:51