看板 EE_DSnP 關於我們 聯絡資訊
順帶問個問題 作業中說不能讓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)
ric2k1:For recursive dofiles, you may need to use a stack to 11/14 22:50
ric2k1:record the calling dofiles. Therefore, you can just 11/14 22:50
ric2k1:test the size of the stack as the recursion depth. 11/14 22:51
BBSealion:OK 那就沒問題了 謝謝 11/14 22:51