From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@chbouib.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: slowness in guile 1.8 Date: Fri, 25 May 2007 20:12:15 +0200 Message-ID: <87tzu0pybk.fsf@chbouib.org> References: <1180110804.4388.16.camel@localhost.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1180116777 2363 80.91.229.12 (25 May 2007 18:12:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 25 May 2007 18:12:57 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri May 25 20:12:55 2007 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HreHT-00069J-Ug for guile-devel@m.gmane.org; Fri, 25 May 2007 20:12:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HreHT-000158-Af for guile-devel@m.gmane.org; Fri, 25 May 2007 14:12:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HreHP-00011I-MD for guile-devel@gnu.org; Fri, 25 May 2007 14:12:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HreHP-00010l-1k for guile-devel@gnu.org; Fri, 25 May 2007 14:12:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HreHO-00010Y-Sp for guile-devel@gnu.org; Fri, 25 May 2007 14:12:46 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HreHO-0008NW-DV for guile-devel@gnu.org; Fri, 25 May 2007 14:12:46 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1HreHF-0004Cc-JU for guile-devel@gnu.org; Fri, 25 May 2007 20:12:37 +0200 Original-Received: from adh419.fdn.fr ([80.67.176.9]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 May 2007 20:12:37 +0200 Original-Received: from ludo by adh419.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 May 2007 20:12:37 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 122 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: adh419.fdn.fr X-URL: http://www.laas.fr/~lcourtes/ X-PGP-Key-ID: 0xEB1F5364 X-PGP-Key: http://www.laas.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i486-pc-linux-gnu User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:uQk96FerlLrotGxZIk2ZdhaUjIM= X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6616 Archived-At: --=-=-= Hello Guilers! Andy Wingo writes: > 2004-12-22 Marius Vollmer > > * boot-9.scm (module-make-local-var!): When creating a new > variable, initialize it to the value of any imported variable with > the given name. This allows code like (define round round) to > work as expected. (See also: http://cvs.savannah.gnu.org/viewvc/guile/guile-core/ice-9/boot-9.scm?root=guile&r1=1.341&r2=1.342) Andy and I discussed this issue on IRC. It turns out that my recent changes in the module system (allowing for lazy duplicate binding checks) revert this change, for the reasons mentioned by Andy ("superfluous" overhead). However, in doing so it breaks `(define round round)' ("unbound variable"). Inverting the order of the calls to `scm_sym2var ()' and `scm_eval_car ()' in `scm_m_define ()' so that it first evaluates the value, and then creates the variable and assigns it the just-evaluated value fixes the problem. Alas, it breaks the following test in `syntax.test': (pass-if "binding is created before expression is evaluated" (= (eval '(begin (define foo (begin (set! foo 1) (+ foo 1))) foo) (interaction-environment)) 2)) This test case illustrates the fact that _internal_ defines are equivalent to `letrec' (Section 5.2.2); top-level defines should behave similarly for new variables (Section 5.2.1). For top-level defines as in `(define round round)', the rule is that `define' is equivalent to `set!' when the variable is already bound (Section 5.2.1). This justifies the change made by Marius to `module-make-local-var!' (above). Consequently: * `module-make-local-var!' cannot be changed in 1.8; * `module-make-local-var!' in HEAD must be reverted to its previous definition (attached patch). This is _very_ unfortunate performance-wise, as Andy noted, but I don't have any better idea ATM. :-( Thanks, Ludovic. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename*=us-ascii''%2c%2cdefine-round-round.diff Content-Description: Reverting `module-make-local-var!' in HEAD --- orig/ice-9/boot-9.scm +++ mod/ice-9/boot-9.scm @@ -1511,10 +1511,22 @@ (module-modified m) b))) - ;; Create a new local variable. - (let ((local-var (make-undefined-variable))) - (module-add! m v local-var) - local-var))) + ;; No local variable yet, so we need to create a new one. That + ;; new variable is initialized with the old imported value of V, + ;; if there is one. This is required by Section 5.2.1 of R5RS which + ;; says that `define' is equivalent to `set!' when V is already bound + ;; (of course here we respect module boundaries so this is not exactly + ;; a `set!'). + (let ((imported-var (module-variable m v)) + (local-var (or (and (module-binder m) + ((module-binder m) m v #t)) + (begin + (let ((answer (make-undefined-variable))) + (module-add! m v answer) + answer))))) + (if (and imported-var (not (variable-bound? local-var))) + (variable-set! local-var (variable-ref imported-var))) + local-var))) ;; module-ensure-local-variable! module symbol ;; --- orig/test-suite/tests/modules.test +++ mod/test-suite/tests/modules.test @@ -118,7 +118,16 @@ (map module-variable (map resolve-interface mods) syms) - locals)))) + locals))) + + (pass-if "redefinition" + (let ((m (make-module))) + (beautify-user-module! m) + + ;; The previous value of `round' must still be visible at the time the + ;; new `round' is defined. + (eval '(define round round) m) + (eq? (module-ref m 'stat) stat)))) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel --=-=-=--