From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.bugs,gmane.lisp.guile.devel Subject: Re: bugreport, concise version Date: Thu, 22 Jan 2004 23:47:43 +0100 Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Message-ID: <87d69b7g8g.fsf@zagadka.ping.de> References: <16397.51592.882068.847986@localhost.localdomain> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1074811960 4080 80.91.224.253 (22 Jan 2004 22:52:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 22 Jan 2004 22:52:40 +0000 (UTC) Cc: bug-guile@gnu.org, Dirk Herrmann , guile-devel@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Jan 22 23:52:29 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ajngb-0003yr-00 for ; Thu, 22 Jan 2004 23:52:29 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ajnfu-0001kv-BK for guile-bugs@m.gmane.org; Thu, 22 Jan 2004 17:51:46 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1Ajnce-0008Ch-Ao for bug-guile@gnu.org; Thu, 22 Jan 2004 17:48:24 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1Ajnc6-0007oq-Kj for bug-guile@gnu.org; Thu, 22 Jan 2004 17:48:22 -0500 Original-Received: from [195.253.8.218] (helo=mail.dokom.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ajnc4-0007mY-Vc for bug-guile@gnu.org; Thu, 22 Jan 2004 17:47:49 -0500 Original-Received: from dialin.net17.dip92.dokom.de ([195.253.17.92] helo=zagadka.ping.de) by mail.dokom.net with smtp (Exim 3.36 #3) id 1Ajncs-0006NK-00 for bug-guile@gnu.org; Thu, 22 Jan 2004 23:48:38 +0100 Original-Received: (qmail 27209 invoked by uid 1000); 22 Jan 2004 22:47:43 -0000 Original-To: hanwen@cs.uu.nl In-Reply-To: <16397.51592.882068.847986@localhost.localdomain> (Han-Wen Nienhuys's message of "Wed, 21 Jan 2004 01:36:24 +0100") User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GUILE, GNU's Ubiquitous Extension Language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.bugs:1121 gmane.lisp.guile.devel:3287 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.bugs:1121 Han-Wen Nienhuys writes: > I consider this a very severe bug. Can you fix this please? Done! Dirk, could you double-check the diff below? I think it is obviously the right thing to do. Without the change, bodies with internal definitions would get expanded on every execution, not just on the first time. 2004-01-22 Marius Vollmer * eval.c (m_expand_body): Rewrite the expression in place (by overwriting FORMS) also when a letrec is constructed, not only when no definitions are found. Do not return rewritten expression to emphasize the in-place rewriting. Changed all users. Index: libguile/eval.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/eval.c,v retrieving revision 1.350 diff -u -r1.350 eval.c --- libguile/eval.c 21 Nov 2003 23:21:34 -0000 1.350 +++ libguile/eval.c 22 Jan 2004 22:41:15 -0000 @@ -764,9 +764,10 @@ } -/* The function m_expand_body memoizes a proper list of expressions forming a - * body. This function takes care of dealing with internal defines and - * transforming them into an equivalent letrec expression. */ +/* The function m_expand_body memoizes a proper list of expressions + * forming a body. This function takes care of dealing with internal + * defines and transforming them into an equivalent letrec expression. + * The list of expressions is rewritten in place. */ /* This is a helper function for m_expand_body. It helps to figure out whether * an expression denotes a syntactic keyword. */ @@ -835,7 +836,7 @@ return 0; } -static SCM +static void m_expand_body (const SCM forms, const SCM env) { /* The first body form can be skipped since it is known to be the ISYM that @@ -948,14 +949,13 @@ /* FIXME: forms does not hold information about the file location. */ letrec_expression = scm_cons_source (forms, scm_sym_letrec, letrec_tail); new_letrec_expression = scm_m_letrec (letrec_expression, env); - new_body = scm_list_1 (new_letrec_expression); - return new_body; + SCM_SETCAR (forms, new_letrec_expression); + SCM_SETCDR (forms, SCM_EOL); } else { SCM_SETCAR (forms, SCM_CAR (sequence)); SCM_SETCDR (forms, SCM_CDR (sequence)); - return forms; } } @@ -967,7 +967,8 @@ { scm_c_issue_deprecation_warning ("`scm_m_expand_body' is deprecated."); - return m_expand_body (exprs, env); + m_expand_body (exprs, env); + return exprs; } #endif @@ -2549,7 +2550,7 @@ scm_rec_mutex_lock (&source_mutex); /* check for race condition */ if (SCM_ISYMP (SCM_CAR (code))) - code = m_expand_body (code, env); + m_expand_body (code, env); scm_rec_mutex_unlock (&source_mutex); goto again; } @@ -2951,7 +2952,7 @@ scm_rec_mutex_lock (&source_mutex); /* check for race condition */ if (SCM_ISYMP (SCM_CAR (x))) - x = m_expand_body (x, env); + m_expand_body (x, env); scm_rec_mutex_unlock (&source_mutex); goto nontoplevel_begin; } @@ -4604,7 +4605,7 @@ scm_rec_mutex_lock (&source_mutex); /* check for race condition */ if (SCM_ISYMP (SCM_CAR (proc))) - proc = m_expand_body (proc, args); + m_expand_body (proc, args); scm_rec_mutex_unlock (&source_mutex); goto again; } -- GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405 _______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://mail.gnu.org/mailman/listinfo/bug-guile