[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] local-eval, local-compile, and the-environment (v3)

From: Mark H Weaver
Subject: Re: [PATCH] local-eval, local-compile, and the-environment (v3)
Date: Mon, 16 Jan 2012 03:44:15 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

David Kastrup <address@hidden> 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) <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

* 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]