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: [PATCH] local-eval, local-compile, and the-environment (v3) Date: Mon, 16 Jan 2012 03:44:15 -0500 Message-ID: <87mx9o2g0w.fsf@netris.org> References: <8762gd5vkl.fsf@netris.org> <87obu52cvx.fsf@fencepost.gnu.org> <871ur06g6r.fsf@netris.org> <87fwfg3lxr.fsf@fencepost.gnu.org> <87wr8s4ytn.fsf@netris.org> <874nvw3jpz.fsf@fencepost.gnu.org> <87obu44wh2.fsf@netris.org> <87vcoc22h8.fsf@fencepost.gnu.org> <874nvw4ubg.fsf@netris.org> <87r4z0208r.fsf@fencepost.gnu.org> <87mx9o1z4n.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1326703510 19258 80.91.229.12 (16 Jan 2012 08:45:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 Jan 2012 08:45:10 +0000 (UTC) Cc: guile-devel@gnu.org To: David Kastrup Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jan 16 09:45:06 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 1RmiBd-00040n-MP for guile-devel@m.gmane.org; Mon, 16 Jan 2012 09:45:05 +0100 Original-Received: from localhost ([::1]:54335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmiBd-0007LP-7w for guile-devel@m.gmane.org; Mon, 16 Jan 2012 03:45:05 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:41589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmiBZ-0007KC-QD for guile-devel@gnu.org; Mon, 16 Jan 2012 03:45:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmiBU-0006LY-57 for guile-devel@gnu.org; Mon, 16 Jan 2012 03:45:01 -0500 Original-Received: from world.peace.net ([96.39.62.75]:35759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmiBU-0006LU-2g; Mon, 16 Jan 2012 03:44:56 -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 1RmiBN-0007ZM-VF; Mon, 16 Jan 2012 03:44:50 -0500 In-Reply-To: <87mx9o1z4n.fsf@fencepost.gnu.org> (David Kastrup's message of "Sun, 15 Jan 2012 21:36:56 +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:13537 Archived-At: David Kastrup writes: > (define current-module > (let ((top-level (the-environment))) > (lambda () (eval '(the-environment) top-level)))) Some more notes about the above code (changing `eval' ==> `local-eval'): * (local-eval '(the-environment) ) is a no-op: it always returns the same environment that was passed in, so there's no point in doing it. * Of course `top-level' is a constant, and would be even if it were within the (lambda () ...) because it captures no lexicals. It is always in the same module, i.e. the module containing the above definition. This same constant value is always returned by (current-module). * Also note that the real `current-module' simply accesses a fluid, which can also be set by `set-current-module'. (Fluids are a scheme analogue to "dynamically-scoped" variables in Lisp). Conceptually, it is variable that is explicitly set by the user. It has no relation to the code that is currently executing. Rather, it is used during compilation (or within a REPL) to keep track of where the user would like top-level definitions to go. Mark