Recursion Limit - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2) +--- Thread: Recursion Limit (/showthread.php?tid=1706) Pages:
1
2
|
Recursion Limit - bplus - 05-28-2023 Ewh! disappointing that QB64pe dies in mid 18,000's BaCon and FreeBasic do way better... https://rosettacode.org/wiki/Find_limit_of_recursion#BASIC Here is code I checked with, maybe there is better? Code: (Select All) howRecursive 1 Maybe with manual stack? RE: Recursion Limit - CharlieJV - 05-28-2023 BAM (well, javascript) chokes at just a little over 526,200. BAM version of the test program: Code: (Select All) Sub howRecursive (i As long) I wanted to see how QBJS handles my BAM program (I was expecting same results), but QBJS is giving the error: Code: (Select All) WARN : 4 : Missing or unsupported method: 'howRecursive(i' - ignoring line RE: Recursion Limit - CharlieJV - 05-28-2023 How interesting is this. Adding additional code in the subroutine causes the BAM program to choke earlier. It kind of makes sense if it is about some memory limit getting reached. Maybe that's what is going on with QB64pe ??? The following version of the program chokes at just a little over 420, 900: Code: (Select All) Sub howRecursive (i As long) RE: Recursion Limit - mnrvovrfc - 05-28-2023 (05-28-2023, 02:04 PM)bplus Wrote: Here is code I checked with, maybe there is better? Without _DELAY and outputting to console: RE: Recursion Limit - dbox - 05-28-2023 (05-28-2023, 02:39 PM)CharlieJV Wrote: I wanted to see how QBJS handles my BAM program (I was expecting same results), but QBJS is giving the error: @bplus' original example runs without modification just fine in QBJS. There were a couple of issues keeping your BAM version from running in QBJS: 1) You are calling a sub with parameters, but without a CALL statement. You need to either remove the parameters or prefix the call to the sub with the CALL statement. 2) Main code must be defined before subs and functions This modified version runs fine: Code: (Select All) howRecursive 1 I would expect some variation between browsers and system specs. I'm running the code in my Edge browser. It's still running now and just passed 13 million: RE: Recursion Limit - bplus - 05-28-2023 Oh you guys and gals have been busy! I was testing other Basics and learned LB could go to 4 million + Well I doubled that in QB64pe v3.7 with same code tip: use a GoSub! Code: (Select All) Dim i As _Integer64 I was up past 8 million or was it 81 million? I stopped program to get my computer back to do more stuff. Oh hey! Works way way way faster w/o delay (the key word = works) Way past 200 million as I write this. 3 Billion+ whats to stop this? The _Integer64 Type I think. Oh got over .5 Billion not 3 Billion, misread numbers: RE: Recursion Limit - Jack - 05-28-2023 @bplus in the QB64pe IDE click on Options->Compiler Settings and in the C++ Linker Flags: put -Wl,--stack,134217728 that's 128MB or 2^27 here's my mod to your code Code: (Select All) $NoPrefix compile to exe and then launch the cmd and from the cmd run your program, if your program dies you will still have the printout in the cmd window here's my result for different linker values 2m 14378 4m 28943 8m 58076 16m 116325 32m 232839 64m 465856 128m 931886 RE: Recursion Limit - CharlieJV - 05-28-2023 (05-28-2023, 06:10 PM)bplus Wrote: Oh you guys and gals have been busy! For the giggles, I decided to do the same sort of thing with BAM, and it conked out at 536.85 million. That's a big difference from before. I'm finding it wildly interesting that both BAM's BASIC interpreter written in javascript and QB64pe's compiled C++ perform both way better using GOSUB instead of Sub. Suddenly, I'm starting to question my attitude towards GOSUB. Code: (Select All) dim as double i RE: Recursion Limit - bplus - 05-28-2023 Quote:if your program dies you will still have the printout in the cmd window Clever @Jack, do you still need delay? I didn't when used the GoSub version. Quote:with BAM, and it conked out at 536.85 million.@CharlieJV Looks like we get similar results with GoSub and yeah, it still has some surprises for us RE: Recursion Limit - bplus - 05-28-2023 @dbox now I see why you wrote the version you did, this is about half an hour in (still running): But without some delay it wont work at all, or just seems to sit there no error, no printing. Without the delay QB64pe just does a wait circle and then crashes. |