guile-user
[Top][All Lists]
Advanced

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

Re: load in environment


From: Stephen Compall
Subject: Re: load in environment
Date: Fri, 06 Jul 2007 02:03:39 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.4) Gecko/20070509 SeaMonkey/1.1.2

Jon Wilson wrote:
I'm not sure if my-table is what you meant by "other guile state" that I might want to modify, but it is definitely something visible to the rest of the program which I want to modify by loading filename.

I'm saying that there are many possible system properties one might want to temporarily change when loading, so it is impractical and asymmetric to exalt one or another as an argument to `load'.

I'm a little bit mystified that I can modify my-table from inside (load filename) at all, since my-table is certainly not visible to the code inside filename. I guess that I can because my-table is wrapped up in the closure of item. I'm not really clear on the interaction between modules (especially set-current-module) and closures. A closure inside of one module can apparently reference and modify things in quite another module altogether.

Your `item' closure carries around an environment, which has as its environment-module the module that contains your `load-data' function. When you call it, even from another environment with a different environment-module, you evaluate its expressions in the environment it captured when it was created. The closure isn't "inside" any module; you merely gave it a binding in your temporary module.

temp-module m
  has #<variable ... value: #<procedure #f (name text number)>
    has #<procedure #f (name text number)> which is eq? to item
      captured the environment containing my-table
        so can refer to my-table when called

--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
But you know how reluctant paranormal phenomena are to reveal
themselves when skeptics are present. --Robert Sheaffer, SkI 9/2003




reply via email to

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