From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: A plea for local-eval in 2.0.4 Date: Fri, 13 Jan 2012 11:21:53 -0500 Message-ID: <8739bj8tem.fsf@netris.org> References: <87aa5s8uli.fsf@netris.org> <8762gg7yco.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1326471761 6515 80.91.229.12 (13 Jan 2012 16:22:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 13 Jan 2012 16:22:41 +0000 (UTC) Cc: guile-devel@gnu.org To: David Kastrup Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 13 17:22:37 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rljtl-0008Ec-DX for guile-devel@m.gmane.org; Fri, 13 Jan 2012 17:22:37 +0100 Original-Received: from localhost ([::1]:50969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rljtk-0001kW-Sl for guile-devel@m.gmane.org; Fri, 13 Jan 2012 11:22:36 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rljti-0001kG-O2 for guile-devel@gnu.org; Fri, 13 Jan 2012 11:22:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rljtc-0005Rw-PH for guile-devel@gnu.org; Fri, 13 Jan 2012 11:22:34 -0500 Original-Received: from world.peace.net ([96.39.62.75]:52351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rljtc-0005Rs-LG; Fri, 13 Jan 2012 11:22:28 -0500 Original-Received: from c-98-216-245-176.hsd1.ma.comcast.net ([98.216.245.176] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1RljtW-00007I-Th; Fri, 13 Jan 2012 11:22:23 -0500 In-Reply-To: <8762gg7yco.fsf@fencepost.gnu.org> (David Kastrup's message of "Fri, 13 Jan 2012 10:20:23 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13478 Archived-At: David Kastrup writes: > I am still fuzzy on what local-eval will do when the current module at > the time of the-environment is different from that at the time of > local-eval. (the-environment) saves the module (where it is textually located) in the lexical environment object. If (the-environment) was passed to `eval', that's the module specified by `eval's second parameter. If (the-environment) was passed to `primitive-eval', then that's the (current-module) at the time primitive-eval was called. `local-eval' passes the saved module to `eval', which temporarily restores it (using dynamic-wind) as the current module during both macro expansion and evaluation of the local expression. `local-compile' passes the saved module as the #:env parameter to `compile', which has the same effect as for `local-eval'. > since the current module, even if nominally the same, can contain > different variables at the time of local-eval, my take on that would be > to not make it part of the environment at all. That is, everything that > is not reachable through local scopes is not part of the environment. I heartily disagree. A module is conceptually part of every lexical environment evaluated within that module. That this makes sense is particularly evident in the case of recursively defined top-level procedures. For example, in (define (factorial n) (if (zero? n) 1 (* n (factorial (- n 1))))) it would be crazy for any lexical variable "search path" starting from within the definition of `factorial' to lead anywhere other than the module where this definition was evaluated, i.e. where the top-level `factorial' was bound. Thanks, Mark