[taos-glug] Re: idle curiosity about factorials
- From: Jonathan Bartlett <johnnyb@xxxxxxxxxx>
- To: taos-glug@xxxxxxxxxxxxx
- Date: Wed, 2 Jul 2003 15:34:58 -0700 (PDT)
Basically, you're running out of stack space. I don't know how big the
Linux stack can grow, but it's likely that your other Scheme
implementations are using the heap rather than the stack for their
procedure calls. Guile uses the C stack so that it can mix with C code
better.
If anyone's interested, Kent Dybvig has an interesting paper on the three
basic models of Scheme interpretters, and Essentials of Programming
Languages shows both stack and continuation-based interpretters.
Anyway, it's more likely a kernel setting (maximum stack size) than a
guile setting.
Jon
On Wed, 2 Jul 2003, Philip Ansteth wrote:
>
> I tried the following program:
>
> (define fact
> (lambda (n)
> (if (= n 0)
> 1
> (* n (fact (- n 1))))))
>
>
> On my Debian Gnu/Linux system,
> running Guile 1.4,
>
> (fact 360) works. But (fact 361) generates
> ERROR: Stack overflow
>
> So do other values larger than 360.
>
> Alternately, on my Windows Me notebook, running CMUScheme,
> the same program gave no error on selected values
> up through (fact 3600).
>
> I'm curious whether other other people get the same
> "Stack overflow" error on their systems.
>
> I suspect I'm failing to set some configuration option on
> guile. Or maybe something about my hardware? The program came
> from the "guile-tutorial" that I access with "info guile-tutorial"
> at the shell prompt. (There it's called "recursive-factorial," but
> that was too much to type over and over.)
>
> Oddly, the tutorial shows (fact 500) working. That's why I suspect
> I'm doing something wrong.
>
> Philip
>
> P.S.
> (fact 10000) on the Windows Me notebook worked--or a least returned without
> an error message.
>
>
- References:
- [taos-glug] idle curiosity about factorials
- From: Philip Ansteth
Other related posts:
- » [taos-glug] idle curiosity about factorials
- » [taos-glug] Re: idle curiosity about factorials
- [taos-glug] idle curiosity about factorials
- From: Philip Ansteth