unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Stephen Compall <s11@member.fsf.org>
Cc: guile-user@gnu.org
Subject: Re: stack overflow problem
Date: Sat, 04 Feb 2006 19:18:13 -0600	[thread overview]
Message-ID: <1139102293.923.16.camel@nocandy.dyndns.org> (raw)
In-Reply-To: <87slqzl7hv.fsf@www.williamxu.com>


[-- Attachment #1.1: Type: text/plain, Size: 1036 bytes --]

On Sat, 2006-02-04 at 18:54 +0800, William Xu wrote:
> (define (enumerate-interval low high)
>   "Return a sequence list by walking from LOW to HIGH.
> e.g.,
>         (enumerate-interval 1 10)
>                                  => (1 2 3 4 5 6 7 8 9 10)"
>   (if (> low high)
>       '()
>       (cons low (enumerate-interval (1+ low) high))))
> 
> When i passed it a slightly big interval, guile complains "stack
> overflow", 
> 
> 
> Might be a bug? (i also tested this on mzscheme, and works fine.)

Sorry, but while optimization of tail calls is guaranteed by R5RS,
non-tail recursion to arbitrary depth is not.  Try rewriting your code
so that the recursive call is the "last thing" done; to see what this
means, consider that in the recursion case, the "last thing" is
currently the call to cons.

See Section 33.3.7.1 (Stack overflow,
http://www.gnu.org/software/guile/docs/guile-ref/Debugger-options.html)
in the Guile Reference for details.

-- 
Stephen Compall
http://scompall.nocandysw.com/blog

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

  parent reply	other threads:[~2006-02-05  1:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-04 10:54 stack overflow problem William Xu
2006-02-04 23:03 ` Chusslove Illich
2006-02-05  1:18 ` Stephen Compall [this message]
2006-02-05 14:08   ` William Xu
2006-02-13 18:08     ` Holger Blasum
  -- strict thread matches above, loose matches on Subject: below --
2006-02-04 17:09 William Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1139102293.923.16.camel@nocandy.dyndns.org \
    --to=s11@member.fsf.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).