Dear Andy, good to know you are playing with the memoize egg. ATM I don't have time to look deeper into the problem you pointed out. Sorry for that. After I finish some personal stuff I'll dig into it.
Cheers, Arthur Em 01/04/2016 11:56, "Andy Bennett" <andy...@ashurst.eu.org> escreveu: > On 01/04/16 15:28, Andy Bennett wrote: > > Hi Peeps! > > > > I'm running CHICKEN 4.9.0rc1 and I'm trying out the memoize egg. > > > > I saw the tail-call-optimized version of the factorial procedure in the > > memoize documentation at http://api.call-cc.org/doc/memoize and I've > > been trying to modify it so that it memoizes intermediate results such > > that, for example, a call to (fact 10) makes a subsequent call to (fact > > 9) fast. > > > > In doing so I've managed to get the interpreter into a loop or crash it > > entirely. > > > > > > When pasting this into a csi prompt: > > > > ----- > > (use numbers) > > (use memoize) > > > > (define (fact** x #!optional (self memo-fact**)) > > (if (= x 0) > > 1 > > (* x (self (- x 1))))) > > > > (define memo-fact** (memoize fact**)) > > > > (define x (time (memo-fact** 35710))) > > (define x (time (memo-fact** 35720))) > > (define x (time (memo-fact** 35730))) > > ----- > > > > I get: > > > > ----- > > $ csi > > > > CHICKEN > > (c) 2008-2014, The Chicken Team > > (c) 2000-2007, Felix L. Winkelmann > > Version 4.9.0rc1 (rev 3cf1967) > > linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ] > > compiled 2014-04-17 on hd-t1179cl (Linux) > > > > ; loading /home/local/andyjpb/.csirc ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/parley.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/chicken.import.so ... > > ; loading > > /usr/local/chicken-4.9.0/lib/chicken/7/data-structures.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/extras.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/ports.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/posix.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-1.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-13.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-18.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/stty.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/srfi-69.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/foreign.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/foreigners.import.so > ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/parley.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/stty.so ... > > #;1> (use numbers) > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/numbers.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/numbers.so ... > > #;2> (use memoize) > > #;2> > > #;2> (define (fact** x #!optional (self memo-fact**)) > > #;2> (if (= x 0) > > #;2> 1 > > #;2> (* x (self (- x 1))))) > > #;2> > > #;2> (define memo-fact** (memoize fact**)) > > #;2> > > #;2> (define x (time (memo-fact** 35710))) > > #;2> (define x (time (memo-fact** 35720))) > > #;2> (define x (time (memo-fact** 35730))) > > #;2> > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/memoize.import.so ... > > ; loading /usr/local/chicken-4.9.0/lib/chicken/7/memoize.so ... > > > > Note: the following toplevel variables are referenced but unbound: > > > > memo-fact** (in fact**) > > 2.804s CPU time, 1.064s GC time (major), 81305 mutations, 21/1551 GCs > > (major/minor) > > 0s CPU time, 20 mutations > > 0s CPU time, 20 mutations > > #;8> > > [panic] out of memory - heap full while resizing - execution terminated > > > > ...more... > > parley.scm:610: history817818 > > parley.scm:610: history817818 > > parley.scm:603: ##sys#dynamic-wind > > parley.scm:603: history798799 > > parley.scm:603: history798799 > > parley.scm:603: history798799 > > parley.scm:603: history798799 > > parley.scm:610: ##sys#dynamic-wind > > parley.scm:610: history817818 > > parley.scm:610: history817818 > > parley.scm:615: get-next-char! > > parley.scm:579: parley-char-ready? > > parley.scm:586: append-while-incomplete > > parley.scm:560: string-null? > > parley.scm:561: repl-prompt > > parley.scm:561: g769 <-- > > ----- > > > > Sometimes I'll crash immediately and someytimes I have to press some > > keys when the "#;8>" prompt appears. > > > > > > If I run the above script thusly: > > > > ----- > > $ csi -s memo-demo.scm > > ----- > > > > I see > > > > ----- > > $ csi -s ../memo-demo.scm > > 2.908s CPU time, 1.164s GC time (major), 75257 mutations, 22/1550 GCs > > (major/minor) > > 0s CPU time, 20 mutations > > ----- > > > > ...and it hangs there (on the last time call) indefinitely using all the > > CPU. Ctrl-C doesn't terminate it: a call to 'killall csi' does tho'. > > > > > > If you cannot reproduce it then try varying the numbers in the call to > > memo-fact**. > > > > > > > > Is this a known bug in Chicken 4.9.0rc1 or the srfi-69 hash-tables that > > memoize uses? > > > > > > Thanks for any tips you can offer. > > With CHICKEN 4.10.0 from the website the following works: > > ----- > (define x (time (memo-fact** 35710))) > (define x (time (memo-fact** 35720))) > (define x (time (memo-fact** 36030))) > ----- > > ...but a slightly larger number hangs as before: > > ----- > (define x (time (memo-fact** 35710))) > (define x (time (memo-fact** 35720))) > (define x (time (memo-fact** 37030))) > ----- > > > > ...Also, under CHICKEN 4.10.0, pasting things into csi with parley gives > errors: > > ----- > $ csi > > CHICKEN > (c) 2008-2015, The CHICKEN Team > (c) 2000-2007, Felix L. Winkelmann > Version 4.10.0 (rev b259631) > linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ] > compiled 2015-08-04 on yves.more-magic.net (Linux) > > ; loading /home/local/andyjpb/.csirc ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/parley.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/chicken.import.so ... > ; loading > /usr/local/chicken-4.10.0/lib/chicken/7/data-structures.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/extras.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/lolevel.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/miscmacros.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/ports.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/posix.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/srfi-1.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/srfi-13.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/srfi-18.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/srfi-71.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/stty.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/srfi-69.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/foreign.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/foreigners.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/parley.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/srfi-71.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/stty.so ... > #;1> (use numbers) > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/numbers.import.so ... > ; loading /usr/local/chicken-4.10.0/lib/chicken/7/numbers.so ... > > Error: (open-input-string) bad argument type - not a string: #f > > Call history: > > parley.scm:294: loop > parley.scm:291: reverse > list->string > parley.scm:291: string-split > parley.scm:292: values > list->string > parley.scm:591: call-with-input-string > parley.scm:595: peek-char > parley.scm:607: restore-terminal-settings > parley.scm:166: stty#set-terminal-attributes! > stty.scm:208: port? > stty.scm:208: port->fileno > parley.scm:612: call-with-current-continuation > parley.scm:612: with-exception-handler > parley.scm:612: ##sys#call-with-values > parley.scm:612: with-input-from-string <-- > #;3> > ----- > > > > > Regards, > @ndy > > -- > andy...@ashurst.eu.org > http://www.ashurst.eu.org/ > 0290 DA75 E982 7D99 A51F E46A 387A 7695 7EBA 75FF > >
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users