From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Compall Newsgroups: gmane.lisp.guile.user Subject: Re: stack overflow problem Date: Sat, 04 Feb 2006 19:18:13 -0600 Message-ID: <1139102293.923.16.camel@nocandy.dyndns.org> References: <87slqzl7hv.fsf@www.williamxu.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0663284565==" X-Trace: sea.gmane.org 1139109714 11806 80.91.229.2 (5 Feb 2006 03:21:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 5 Feb 2006 03:21:54 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Feb 05 04:21:44 2006 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F5aT3-0003eu-Dh for guile-user@m.gmane.org; Sun, 05 Feb 2006 04:21:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F5aWH-0001mp-A8 for guile-user@m.gmane.org; Sat, 04 Feb 2006 22:24:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F5Yb4-0002a1-EP for guile-user@gnu.org; Sat, 04 Feb 2006 20:21:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F5Yb0-0002Yh-GI for guile-user@gnu.org; Sat, 04 Feb 2006 20:21:45 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F5Yax-0002YK-Jy for guile-user@gnu.org; Sat, 04 Feb 2006 20:21:42 -0500 Original-Received: from [63.240.76.165] (helo=sccimhc91.asp.att.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1F5YaF-0000Tr-QU for guile-user@gnu.org; Sat, 04 Feb 2006 20:20:55 -0500 Original-Received: from . (12-222-181-59.client.insightbb.com[12.222.181.59]) by sccimhc91.asp.att.net (sccimhc91) with SMTP id <20060205011814i9100fubcee>; Sun, 5 Feb 2006 01:18:18 +0000 Original-To: William Xu In-Reply-To: <87slqzl7hv.fsf@www.williamxu.com> X-Mailer: Evolution 2.2.3-10mdk X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5130 Archived-At: --===============0663284565== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-ScuRx4Pt0/e70nHfedSj" --=-ScuRx4Pt0/e70nHfedSj Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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) > =3D> (1 2 3 4 5 6 7 8 9 10)" > (if (> low high) > '() > (cons low (enumerate-interval (1+ low) high)))) >=20 > When i passed it a slightly big interval, guile complains "stack > overflow",=20 >=20 >=20 > 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. --=20 Stephen Compall http://scompall.nocandysw.com/blog --=-ScuRx4Pt0/e70nHfedSj Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQBD5VJVYWjD35Pp0wIRAu6PAJ0f18EuIBbBnBK1p3MgR1Pt9KDzOwCgnXoB 3qj9w9UIB52j+USOjPZ76SQ= =xpSk -----END PGP SIGNATURE----- --=-ScuRx4Pt0/e70nHfedSj-- --===============0663284565== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user --===============0663284565==--