From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.bugs Subject: Re: Strange undefined binding bug coupled to module system Date: Sun, 24 Oct 2004 20:55:21 +0200 Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Message-ID: References: Reply-To: djurfeldt@nada.kth.se NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1098644146 1906 80.91.229.6 (24 Oct 2004 18:55:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Oct 2004 18:55:46 +0000 (UTC) Cc: djurfeldt@nada.kth.se Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Oct 24 20:55:30 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CLnWb-0007GO-00 for ; Sun, 24 Oct 2004 20:55:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CLneC-00030d-SX for guile-bugs@m.gmane.org; Sun, 24 Oct 2004 15:03:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CLne9-0002y3-Sr for bug-guile@gnu.org; Sun, 24 Oct 2004 15:03:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CLne9-0002xg-EN for bug-guile@gnu.org; Sun, 24 Oct 2004 15:03:17 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CLne9-0002xV-BZ for bug-guile@gnu.org; Sun, 24 Oct 2004 15:03:17 -0400 Original-Received: from [213.212.20.77] (helo=kvast.blakulla.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CLnWV-0005pD-23 for bug-guile@gnu.org; Sun, 24 Oct 2004 14:55:23 -0400 Original-Received: from mamaliga.blakulla.net ([213.212.21.241] helo=witch) by kvast.blakulla.net with esmtp (Exim 3.36 #1 (Debian)) id 1CLnWT-0003fa-00; Sun, 24 Oct 2004 20:55:21 +0200 Original-Received: from mdj by witch with local (Exim 4.34) id 1CLnWT-0002K9-Ho; Sun, 24 Oct 2004 20:55:21 +0200 Original-To: bug-guile@gnu.org, dirk@dirk-herrmanns-seiten.de, Marius Vollmer In-Reply-To: (Mikael Djurfeldt's message of "Wed, 20 Oct 2004 15:12:21 +0200") User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 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:1872 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.bugs:1872 Mikael Djurfeldt writes: > Loading of the following code: > > foo.scm: > ---------------------------------------------------------------------- > (define-module (foo)) > > (define (encapsulate proc) > (lambda (_) (proc _))) > > (display round) > (newline) > (define round (encapsulate round)) > ---------------------------------------------------------------------- > > Gives (since some change during last spring): > > guile> (load "foo.scm") > # > > Backtrace: > In unknown file: > ?: 0* [primitive-load "foo.scm"] > In foo.scm: > 8: 1* (define round (encapsulate round)) > 8: 2* [encapsulate ... > > foo.scm:8:15: While evaluating arguments to encapsulate in expression (encapsulate round): > foo.scm:8:15: Unbound variable: round > ABORT: (unbound-variable) OK, I've found the change which causes it: 2004-04-22 Dirk Herrmann (scm_m_define): Change order to first create binding and evaluating the expression afterwards. While this change works in the R5RS situation without a module system, the presence of a module system, with the difference between imported and local bindings, introduces complications. It seems like, in the case where no local binding exists before, that local binding should be created *initialized* to the value of the corresponding imported binding, if that exists. That is not done now, which causes the above described non-intuitive behavior. Since it's not immediately obvious to me how to fix this in a good way, I'll leave that to you guys. But please keep in mind that variable lookup is a substantial part of loading time in Guile. We wouldn't want to make *two* eval closure traversals by invoking scm_sym2var twice (with different value of definep) or something like that. M _______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://lists.gnu.org/mailman/listinfo/bug-guile