> On Friday, June 10, 2016 3:31 PM, Matthew Keeter <matt.j.kee...@gmail.com>
> wrote:
> > The specific use case is for dataflow graphs, where you’re evaluating a
> > bunch of
> small
> snippets of code that can refer to each other by name.
>
> I’d like to make an environment in which the variables in the same subgraph
> are
> exposed as no-argument thunks.
>
> For example, let’s say I have one subgraph that contains
> a = “12” => evaluates to 12
> b = “(+ 1 (a))” => evaluates to 13, since the (a) thunk evaluates to 12
>
> and another subgraph which contains
> x = “1” => evaluates to 1
> y = “(* (x) 2)” => evaluates to 2
>
> If I insert the thunks into (scheme-report-environment 5), they leak from one
> graph
> to another – and to be fair, the docs to say that assigning into this
> environment is
> undefined behavior.
>
> However, if I make an empty environment with (null-environment), it doesn’t
> have
> useful functions like + and *; looks like (make-module) has the same issue.
>
> I'm sure that this is possible in Guile, but I got tired of reading through
> the source
> files to hunt down undocumented function that do what I need [1].
>
> -Matt
>
> [1] Another recent incident: How do you programmatically list all of the
> variables in a module?
> You search the web, find http://www.draketo.de/proj/guile-basics/#sec-3-2,
> see a
> a reference to
> module-map, which doesn’t exist in the documentation, dig it up in the source
> to
> see its
> arguments, etc…
I used something like this, once.
(define (buffer-local-variables)
"Return a list of the buffer-local variables in the current buffer"
(hash-map->list cons (module-obarray (current-module))))
See it in context here.
https://github.com/spk121/zile/blob/guile/src/zile.scm
-Mike