* New to the group...
@ 2006-05-04 5:52 Jason Meade
2006-05-04 6:33 ` David Pirotte
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jason Meade @ 2006-05-04 5:52 UTC (permalink / raw)
Hi All,
My name's Jason. I'm new to Scheme, but am definitely a fan! It seems
to me that extensible and embeddable frameworks are the new
programming model for the 21st century. I'd like to see guile grow in
this respect, and am able to contribute however possible. :)
I've recently got guile 1.6 built from sources on my mac, and am
working on getting 1.8 set up on my freebsd machine.
Initially, I'd like to take a look at why guile bombs on recursive
algorithms. For example:
(define fact
(lambda (n)
(cond
((= n 1) 1)
(else
(* n (fact (- n 1)))))))
guile> (fact 69)
171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
guile> (fact 70)
ERROR: Stack overflow
ABORT: (stack-overflow)
This does not seem right... I can rework fact to use an accumulator,
but that seems a big kludgy, especially since I can run this same
program under chicken with an aguments well into the thousands without
any problems (aside from returning infinity as the result, that is!
;))
Anyway, I'm looking forward to learning more about this software.Thanks
-Jason
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: New to the group...
2006-05-04 5:52 New to the group Jason Meade
@ 2006-05-04 6:33 ` David Pirotte
2006-05-04 13:08 ` Ludovic Courtès
2006-05-04 15:57 ` Neil Jerram
2 siblings, 0 replies; 4+ messages in thread
From: David Pirotte @ 2006-05-04 6:33 UTC (permalink / raw)
Cc: guile-devel
On Wed, 3 May 2006 22:52:32 -0700
"Jason Meade" <jemeade@gmail.com> wrote:
Hi Jason,
you have the opportunity to look at (debug-options) and change the stack size
(debug-set! stack ...), see below
http://www.gnu.org/software/guile/docs/docs-1.6/guile-ref/User-level-options-interfaces.html#User%20level%20options%20interfaces
> guile> (fact 70)
> ERROR: Stack overflow
> ABORT: (stack-overflow)
guile> (debug-options)
(show-file-name #t stack 20000 debug depth 20 maxdepth 1000 frames 3 indent 10 width 79 procnames cheap)
guile> (debug-set! stack 200000)
(show-file-name #t stack 200000 debug depth 20 maxdepth 1000 frames 3 indent 10 width 79 procnames cheap)
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: New to the group...
2006-05-04 5:52 New to the group Jason Meade
2006-05-04 6:33 ` David Pirotte
@ 2006-05-04 13:08 ` Ludovic Courtès
2006-05-04 15:57 ` Neil Jerram
2 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2006-05-04 13:08 UTC (permalink / raw)
Cc: guile-devel
Hi,
"Jason Meade" <jemeade@gmail.com> writes:
> (define fact
> (lambda (n)
> (cond
> ((= n 1) 1)
> (else
> (* n (fact (- n 1)))))))
>
> guile> (fact 69)
> 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
> guile> (fact 70)
> ERROR: Stack overflow
> ABORT: (stack-overflow)
Your definition of `fact' is not tail-recursive, i.e., for each
recursive call, a new stack frame is created. In order to remove this
problem, you have to rewrite `fact' so that it is tail-recursive (which
means that the function returns immediately after the recursive call):
this way Guile will not create any new stack frame for the recursive
calls.
See for instance the definition of `tail-factorial' there:
http://sourceware.org/ml/guile/2000-06/msg00074.html .
Thanks,
Ludovic.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: New to the group...
2006-05-04 5:52 New to the group Jason Meade
2006-05-04 6:33 ` David Pirotte
2006-05-04 13:08 ` Ludovic Courtès
@ 2006-05-04 15:57 ` Neil Jerram
2 siblings, 0 replies; 4+ messages in thread
From: Neil Jerram @ 2006-05-04 15:57 UTC (permalink / raw)
Cc: guile-devel
"Jason Meade" <jemeade@gmail.com> writes:
> My name's Jason. I'm new to Scheme, but am definitely a fan! It seems
> to me that extensible and embeddable frameworks are the new
> programming model for the 21st century. I'd like to see guile grow in
> this respect, and am able to contribute however possible. :)
Nice to meet you!
> Initially, I'd like to take a look at why guile bombs on recursive
> algorithms. For example:
>
> (define fact
> (lambda (n)
> (cond
> ((= n 1) 1)
> (else
> (* n (fact (- n 1)))))))
>
> guile> (fact 69)
> 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
> guile> (fact 70)
> ERROR: Stack overflow
> ABORT: (stack-overflow)
This is a feature: if you write a program by mistake that recurses
forever using more and more stack, Guile will catch it for you.
If you'd like to disable this checking, just say (debug-set! stack 0).
Regards,
Neil
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-05-04 15:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-04 5:52 New to the group Jason Meade
2006-05-04 6:33 ` David Pirotte
2006-05-04 13:08 ` Ludovic Courtès
2006-05-04 15:57 ` Neil Jerram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).