* Transient environment with standard functions
@ 2016-05-28 20:16 Matthew Keeter
2016-06-10 18:18 ` Basa Centro
0 siblings, 1 reply; 16+ messages in thread
From: Matthew Keeter @ 2016-05-28 20:16 UTC (permalink / raw)
To: guile-user
I’m trying to generate a temporary, transient environment that a useful set of functions in it.
The use case is eval’ing a set of small code strings. Each environment needs to be
independent, so previous eval’s don’t leave anything in the environment.
I can make a dummy environment with (null-environment 5), but it’s missing everything
useful. Calling (scheme-report-environment 5) gives me a useful environment, but the
environment is shared (so effects from one eval can carry over, which is undesirable).
Any pointers? (resolve-module) seems like it could be useful, but the #:version argument
doesn’t seem to work.
Thanks,
Matt
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-05-28 20:16 Transient environment with standard functions Matthew Keeter
@ 2016-06-10 18:18 ` Basa Centro
2016-06-10 18:44 ` Matthew Keeter
0 siblings, 1 reply; 16+ messages in thread
From: Basa Centro @ 2016-06-10 18:18 UTC (permalink / raw)
To: Matthew Keeter; +Cc: guile-user
Hi Matthew,
[I know this reply is a little delayed. Please let us know how you
did it if you have already solved the problem.]
Are you using eval-string?
https://www.gnu.org/software/guile/manual/html_node/Fly-Evaluation.html#Fly-Evaluation
It might help for you to post a minimal code sample of what "almost
works" and point out what doesn't. Also, there may be a simpler
technique for what you are trying to accomplish--can you backtrack us
to a higher level motivation? It seems like you need a read-only
environment with a read/write one added on.
(Basa)
On 5/28/16, Matthew Keeter <matt.j.keeter@gmail.com> wrote:
> I’m trying to generate a temporary, transient environment that a useful set
> of functions in it.
>
> The use case is eval’ing a set of small code strings. Each environment
> needs to be
> independent, so previous eval’s don’t leave anything in the environment.
>
> I can make a dummy environment with (null-environment 5), but it’s missing
> everything
> useful. Calling (scheme-report-environment 5) gives me a useful
> environment, but the
> environment is shared (so effects from one eval can carry over, which is
> undesirable).
>
> Any pointers? (resolve-module) seems like it could be useful, but the
> #:version argument
> doesn’t seem to work.
>
> Thanks,
> Matt
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 18:18 ` Basa Centro
@ 2016-06-10 18:44 ` Matthew Keeter
2016-06-10 20:39 ` Basa Centro
2016-06-10 22:35 ` Chris Vine
0 siblings, 2 replies; 16+ messages in thread
From: Matthew Keeter @ 2016-06-10 18:44 UTC (permalink / raw)
To: Basa Centro; +Cc: guile-user
Thanks for the reply!
You’ll be sad to hear that I’ve solved the problem by switching to Racket –
(make-base-namespace) creates the kind of temporary environment I needed,
and multiple calls produce multiple independent namespaces.
-Matt
On Jun 10, 2016, at 2:18 PM, Basa Centro <basa.centro@gmail.com> wrote:
> Hi Matthew,
>
> [I know this reply is a little delayed. Please let us know how you
> did it if you have already solved the problem.]
>
> Are you using eval-string?
>
> https://www.gnu.org/software/guile/manual/html_node/Fly-Evaluation.html#Fly-Evaluation
>
> It might help for you to post a minimal code sample of what "almost
> works" and point out what doesn't. Also, there may be a simpler
> technique for what you are trying to accomplish--can you backtrack us
> to a higher level motivation? It seems like you need a read-only
> environment with a read/write one added on.
>
> (Basa)
>
>
> On 5/28/16, Matthew Keeter <matt.j.keeter@gmail.com> wrote:
>> I’m trying to generate a temporary, transient environment that a useful set
>> of functions in it.
>>
>> The use case is eval’ing a set of small code strings. Each environment
>> needs to be
>> independent, so previous eval’s don’t leave anything in the environment.
>>
>> I can make a dummy environment with (null-environment 5), but it’s missing
>> everything
>> useful. Calling (scheme-report-environment 5) gives me a useful
>> environment, but the
>> environment is shared (so effects from one eval can carry over, which is
>> undesirable).
>>
>> Any pointers? (resolve-module) seems like it could be useful, but the
>> #:version argument
>> doesn’t seem to work.
>>
>> Thanks,
>> Matt
>>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 18:44 ` Matthew Keeter
@ 2016-06-10 20:39 ` Basa Centro
2016-06-10 21:11 ` Taylan Ulrich Bayırlı/Kammer
2016-06-10 22:35 ` Chris Vine
1 sibling, 1 reply; 16+ messages in thread
From: Basa Centro @ 2016-06-10 20:39 UTC (permalink / raw)
To: guile-user; +Cc: matt.j.keeter
Matt and List,
As a matter of fact, I've been thinking about defecting to MIT/GNU
Scheme if I don't get better support for scmutils and C++ FFI. :)
Come on now Guilers, we can't have people defecting to Racket.
Is there equivalent functionality in Guile to Racket's
make-base-namespace, as Matt needs? It does seem like Guile's module
system should handle this.
Let's help Matt. Esprit de Guile!
(Basa)
On 6/10/16, Matthew Keeter <matt.j.keeter@gmail.com> wrote:
> Thanks for the reply!
>
> You’ll be sad to hear that I’ve solved the problem by switching to Racket –
> (make-base-namespace) creates the kind of temporary environment I needed,
> and multiple calls produce multiple independent namespaces.
>
> -Matt
>
> On Jun 10, 2016, at 2:18 PM, Basa Centro <basa.centro@gmail.com> wrote:
>
>> Hi Matthew,
>>
>> [I know this reply is a little delayed. Please let us know how you
>> did it if you have already solved the problem.]
>>
>> Are you using eval-string?
>>
>> https://www.gnu.org/software/guile/manual/html_node/Fly-Evaluation.html#Fly-Evaluation
>>
>> It might help for you to post a minimal code sample of what "almost
>> works" and point out what doesn't. Also, there may be a simpler
>> technique for what you are trying to accomplish--can you backtrack us
>> to a higher level motivation? It seems like you need a read-only
>> environment with a read/write one added on.
>>
>> (Basa)
>>
>>
>> On 5/28/16, Matthew Keeter <matt.j.keeter@gmail.com> wrote:
>>> I’m trying to generate a temporary, transient environment that a useful
>>> set
>>> of functions in it.
>>>
>>> The use case is eval’ing a set of small code strings. Each environment
>>> needs to be
>>> independent, so previous eval’s don’t leave anything in the environment.
>>>
>>> I can make a dummy environment with (null-environment 5), but it’s
>>> missing
>>> everything
>>> useful. Calling (scheme-report-environment 5) gives me a useful
>>> environment, but the
>>> environment is shared (so effects from one eval can carry over, which is
>>> undesirable).
>>>
>>> Any pointers? (resolve-module) seems like it could be useful, but the
>>> #:version argument
>>> doesn’t seem to work.
>>>
>>> Thanks,
>>> Matt
>>>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 20:39 ` Basa Centro
@ 2016-06-10 21:11 ` Taylan Ulrich Bayırlı/Kammer
2016-06-10 22:11 ` Basa Centro
0 siblings, 1 reply; 16+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2016-06-10 21:11 UTC (permalink / raw)
To: Basa Centro; +Cc: guile-user, matt.j.keeter
Basa Centro <basa.centro@gmail.com> writes:
> Matt and List,
>
> As a matter of fact, I've been thinking about defecting to MIT/GNU
> Scheme if I don't get better support for scmutils and C++ FFI. :)
>
> Come on now Guilers, we can't have people defecting to Racket.
>
> Is there equivalent functionality in Guile to Racket's
> make-base-namespace, as Matt needs? It does seem like Guile's module
> system should handle this.
>
> Let's help Matt. Esprit de Guile!
>
> (Basa)
First of all: is the "sandboxing" aspect of these environment important?
Because Guile uses psyntax so far, which allows "injecting" absolute
references to any binding in any module in the runtime. For instance,
enter the following into a Guile REPL:
#(syntax-object proper-list? ((top)) (hygiene srfi srfi-1))
It will return the 'proper-list?' procedure defined in (srfi srfi-1)
even though we didn't import that module!
If that's acceptable, then you can create new environment objects with
'make-module' and add bindings to it with some of the interfaces
explained in: (info "(guile) Module System Reflection")
Equivalent web link:
https://www.gnu.org/software/guile/manual/html_node/Module-System-Reflection.html
For instance, the unmerged r7rs-wip branch defines the 'environment'
procedure of R7RS like this:
(define (environment . import-sets)
(let ((m (make-module)))
(module-use-interfaces! m (map resolve-r6rs-interface import-sets))
m))
(Switch to the r7rs-wip branch and see file 'module/scheme/eval.scm'.)
Hope that helps :-)
Taylan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 21:11 ` Taylan Ulrich Bayırlı/Kammer
@ 2016-06-10 22:11 ` Basa Centro
2016-06-10 22:31 ` Matthew Keeter
0 siblings, 1 reply; 16+ messages in thread
From: Basa Centro @ 2016-06-10 22:11 UTC (permalink / raw)
To: Taylan Ulrich Bayırlı/Kammer; +Cc: guile-user, matt.j.keeter
> First of all: is the "sandboxing" aspect of these environment important?
Taylan,
Thanks, that's exactly what I meant by "motivation" in my first reply.
(There was a recent, 6 months ago or so, thread on sandboxing in
guile-user by the way.)
Was Matt trying to prevent _access_ (inaccessible vs. read-only vs.
read/write) to data? Or was he trying to prevent only _visibility_
(e.g. for hygeine)?
I think we need to know more about "what" and "why" to answer his
question, rather than just "how"--if that makes any sense. Does
Racket [1] even _really_ achieve what he needs to do (_prevent_ access
for example)? We don't even know if we don't understand the
higher-level purpose.
(Basa)
[1] Disclaimer: I like Racket too--it is a great project. I just hate
to see someone leave Guile because of a minor technicality.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 22:11 ` Basa Centro
@ 2016-06-10 22:31 ` Matthew Keeter
2016-06-10 22:49 ` Mike Gran
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Matthew Keeter @ 2016-06-10 22:31 UTC (permalink / raw)
To: Basa Centro; +Cc: guile-user
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…
On Jun 10, 2016, at 6:11 PM, Basa Centro <basa.centro@gmail.com> wrote:
>> First of all: is the "sandboxing" aspect of these environment important?
>
> Taylan,
>
> Thanks, that's exactly what I meant by "motivation" in my first reply.
> (There was a recent, 6 months ago or so, thread on sandboxing in
> guile-user by the way.)
>
> Was Matt trying to prevent _access_ (inaccessible vs. read-only vs.
> read/write) to data? Or was he trying to prevent only _visibility_
> (e.g. for hygeine)?
>
> I think we need to know more about "what" and "why" to answer his
> question, rather than just "how"--if that makes any sense. Does
> Racket [1] even _really_ achieve what he needs to do (_prevent_ access
> for example)? We don't even know if we don't understand the
> higher-level purpose.
>
> (Basa)
>
> [1] Disclaimer: I like Racket too--it is a great project. I just hate
> to see someone leave Guile because of a minor technicality.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 18:44 ` Matthew Keeter
2016-06-10 20:39 ` Basa Centro
@ 2016-06-10 22:35 ` Chris Vine
1 sibling, 0 replies; 16+ messages in thread
From: Chris Vine @ 2016-06-10 22:35 UTC (permalink / raw)
To: guile-user
On Fri, 10 Jun 2016 14:44:43 -0400
Matthew Keeter <matt.j.keeter@gmail.com> wrote:
> Thanks for the reply!
>
> You’ll be sad to hear that I’ve solved the problem by switching to
> Racket – (make-base-namespace) creates the kind of temporary
> environment I needed, and multiple calls produce multiple independent
> namespaces.
With guile, the undocumented 'make-fresh-user-module' procedure probably
does what you want. It constructs a new top level for the thread of
execution which calls it, which is unique as against any other top
level. Whether it is what you want depends on what you mean by an
"environment", which is not necessarily the same as a "namespace". If
you are after a new namespace, make-fresh-user-module should do it.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 22:31 ` Matthew Keeter
@ 2016-06-10 22:49 ` Mike Gran
2016-06-10 23:08 ` Taylan Ulrich Bayırlı/Kammer
2016-06-11 15:15 ` Basa Centro
2 siblings, 0 replies; 16+ messages in thread
From: Mike Gran @ 2016-06-10 22:49 UTC (permalink / raw)
To: Matthew Keeter, Basa Centro; +Cc: guile-user@gnu.org
> On Friday, June 10, 2016 3:31 PM, Matthew Keeter <matt.j.keeter@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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 22:31 ` Matthew Keeter
2016-06-10 22:49 ` Mike Gran
@ 2016-06-10 23:08 ` Taylan Ulrich Bayırlı/Kammer
2016-06-11 15:15 ` Basa Centro
2 siblings, 0 replies; 16+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2016-06-10 23:08 UTC (permalink / raw)
To: Matthew Keeter; +Cc: guile-user
Matthew Keeter <matt.j.keeter@gmail.com> writes:
> 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.
Adding the (guile) module to the environment is going to provide a sane
base environment.
Let's implement something like R7RS's 'environment':
(define (environment . modules)
(let ((m (make-module)))
(module-use-interfaces! m (map resolve-interface modules))
m))
Now we can:
(eval '(+ 1 2) (environment '(guile))) => 3
The environments returned from 'environment' are mutable, but unique:
(define e1 (environment '(guile)))
(eval '(define x 'x) e1)
(eval 'x e1) => x
(define e2 (environment '(guile)))
(eval 'x e2) ;ERROR: Unbound variable: x
> 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].
I sympathize. :-) Racket has a ton of personpower behind it, which other
Scheme implementations often can't compete with...
> [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…
Indeed, Guile's module API in particular is badly documented. Maybe
I'll work on it in the coming weeks; I'll have some spare time.
In case you're still interested though, here's how I quickly found out
how to use module-map in Guile's REPL:
scheme@(guile-user)> module-map
$7 = #<procedure module-map (proc module)>
This tells me it takes two arguments: a procedure and a module. Let's
see what arguments it passes to the procedure:
scheme@(guile-user)> (module-map (lambda args
(display args)
(newline))
e1)
;; output:
(x #<variable 1e45640 value: x>)
(Reusing the 'e1' from the previous example.)
So proc is called with a symbol that's the variable's name, and a
variable object. Those are documented in: (info "(guile) Variables")
It's noteworthy also that imported modules' variables aren't listed;
otherwise all of (guile)'s variables would have been listed too.
Taylan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-10 22:31 ` Matthew Keeter
2016-06-10 22:49 ` Mike Gran
2016-06-10 23:08 ` Taylan Ulrich Bayırlı/Kammer
@ 2016-06-11 15:15 ` Basa Centro
2016-06-11 19:44 ` Matthew Keeter
2 siblings, 1 reply; 16+ messages in thread
From: Basa Centro @ 2016-06-11 15:15 UTC (permalink / raw)
To: Matthew Keeter; +Cc: guile-user
It seems in essence you are building up a Scheme expression using the
graph and the code snippets and evaluating that expression. If this
is the case, do you even need to use a module system and/or to
explicitly create environments? Prima facie, it looks like you are
trying to reinvent the wheel. Is your graph really just equivalent to
an S-exp?
Scheme is lexically scoped, and creates a "transient environment" for
you through the use of lambdas.
Your use of thunks suggests that you are doing caching or lazy-eval.
I'm not sure this helps, but I hope so. When thinking about this
topic, I had this mental image of a GUI for building Scheme
expressions--like "Visual Scheme". :)
(Basa)
On 6/10/16, Matthew Keeter <matt.j.keeter@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…
>
> On Jun 10, 2016, at 6:11 PM, Basa Centro <basa.centro@gmail.com> wrote:
>
>>> First of all: is the "sandboxing" aspect of these environment important?
>>
>> Taylan,
>>
>> Thanks, that's exactly what I meant by "motivation" in my first reply.
>> (There was a recent, 6 months ago or so, thread on sandboxing in
>> guile-user by the way.)
>>
>> Was Matt trying to prevent _access_ (inaccessible vs. read-only vs.
>> read/write) to data? Or was he trying to prevent only _visibility_
>> (e.g. for hygeine)?
>>
>> I think we need to know more about "what" and "why" to answer his
>> question, rather than just "how"--if that makes any sense. Does
>> Racket [1] even _really_ achieve what he needs to do (_prevent_ access
>> for example)? We don't even know if we don't understand the
>> higher-level purpose.
>>
>> (Basa)
>>
>> [1] Disclaimer: I like Racket too--it is a great project. I just hate
>> to see someone leave Guile because of a minor technicality.
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-11 15:15 ` Basa Centro
@ 2016-06-11 19:44 ` Matthew Keeter
0 siblings, 0 replies; 16+ messages in thread
From: Matthew Keeter @ 2016-06-11 19:44 UTC (permalink / raw)
To: Basa Centro; +Cc: guile-user
Yes, the graph is equivalent to an s-expr (with subgraphs being nested scopes).
The reason that I’m not just representing the graph as a single expression is for
efficiency – I’m doing incremental updates and change tracking, so you can update
one of the node's expressions and have the changes propagate through the graph
with a minimum number of re-evaluations.
A similar Python engine is documented here:
http://www.mattkeeter.com/projects/graph/
Regards,
Matt
On Jun 11, 2016, at 11:15 AM, Basa Centro <basa.centro@gmail.com> wrote:
> It seems in essence you are building up a Scheme expression using the
> graph and the code snippets and evaluating that expression. If this
> is the case, do you even need to use a module system and/or to
> explicitly create environments? Prima facie, it looks like you are
> trying to reinvent the wheel. Is your graph really just equivalent to
> an S-exp?
>
> Scheme is lexically scoped, and creates a "transient environment" for
> you through the use of lambdas.
>
> Your use of thunks suggests that you are doing caching or lazy-eval.
>
> I'm not sure this helps, but I hope so. When thinking about this
> topic, I had this mental image of a GUI for building Scheme
> expressions--like "Visual Scheme". :)
>
> (Basa)
>
> On 6/10/16, Matthew Keeter <matt.j.keeter@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…
>>
>> On Jun 10, 2016, at 6:11 PM, Basa Centro <basa.centro@gmail.com> wrote:
>>
>>>> First of all: is the "sandboxing" aspect of these environment important?
>>>
>>> Taylan,
>>>
>>> Thanks, that's exactly what I meant by "motivation" in my first reply.
>>> (There was a recent, 6 months ago or so, thread on sandboxing in
>>> guile-user by the way.)
>>>
>>> Was Matt trying to prevent _access_ (inaccessible vs. read-only vs.
>>> read/write) to data? Or was he trying to prevent only _visibility_
>>> (e.g. for hygeine)?
>>>
>>> I think we need to know more about "what" and "why" to answer his
>>> question, rather than just "how"--if that makes any sense. Does
>>> Racket [1] even _really_ achieve what he needs to do (_prevent_ access
>>> for example)? We don't even know if we don't understand the
>>> higher-level purpose.
>>>
>>> (Basa)
>>>
>>> [1] Disclaimer: I like Racket too--it is a great project. I just hate
>>> to see someone leave Guile because of a minor technicality.
>>
>>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
@ 2016-06-11 23:07 Basa Centro
0 siblings, 0 replies; 16+ messages in thread
From: Basa Centro @ 2016-06-11 23:07 UTC (permalink / raw)
To: matt.j.keeter; +Cc: guile-user
> Yes, the graph is equivalent to an s-expr (with subgraphs being nested scopes).
>
> The reason that I’m not just representing the graph as a single expression is
> for
> efficiency – I’m doing incremental updates and change tracking, so you can
> update
> one of the node's expressions and have the changes propagate through the graph
> with a minimum number of re-evaluations.
>
> A similar Python engine is documented here:
> http://www.mattkeeter.com/projects/graph/
Matt [and List],
Sorry if your reply bounced, I was having email issues today. :(
Wow, I think I finally comprehend what you are doing. I seem to
remember looking at the code for a 3D scene graph in Scheme--where
escapes me right now. I think they used Scheme "promises" to cache
values, again a lambda technique.
In any event, if you are translating from Python, I would encourage you
to rethink what you are doing in light of Scheme's facilities. A
constraint solver might be straight-forward, as well. Scheme is really
good at what you are trying to do, built-in.
[
And if anyone else has ideas on this topic of optimizing the update of
an S-exp as Matt has explained--I would be interested too. It would be
awesome to have something like Matt's Antimony done in Guile, trust me:
http://www.mattkeeter.com/projects/antimony/3/
]
Have fun,
(Basa)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
@ 2016-06-12 0:51 Basa Centro
2016-06-26 21:29 ` Amirouche Boubekki
0 siblings, 1 reply; 16+ messages in thread
From: Basa Centro @ 2016-06-12 0:51 UTC (permalink / raw)
To: matt.j.keeter; +Cc: guile-user
I did think of one project that uses a Lisp (CL) to let you do CAD in an
Emacs REPL, rather than a GUI, which is Gendl:
Demo:
https://www.youtube.com/watch?v=yTcxNaBKTOc
Repo:
https://gitlab.common-lisp.net/gendl/gendl
If you haven't seen it, it uses a declarative syntax to avoid some of
the sandboxing issues needed for public model "commons", and I think it
does have a constraint solver to do something similar to your graph. It
has web based tool to display models in X3DOM/WebGL. It doesn't get
enough attention, IMO. Again it is something I wish we had in Guile or
at least Scheme.
I myself have contemplated using an implicit modeling backend with
Sussman et al's. propagator concept to do the constraint solving, but
that is a ways off I am afraid.
(Basa)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
2016-06-12 0:51 Basa Centro
@ 2016-06-26 21:29 ` Amirouche Boubekki
0 siblings, 0 replies; 16+ messages in thread
From: Amirouche Boubekki @ 2016-06-26 21:29 UTC (permalink / raw)
To: Basa Centro; +Cc: matt.j.keeter, guile-user, guile-user
On 2016-06-12 02:51, Basa Centro wrote:
>
> I myself have contemplated using an implicit modeling backend with
> Sussman et al's. propagator concept to do the constraint solving, but
> that is a ways off I am afraid.
Why do you think Sussman et al's. propagator don't solve OP problem?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Transient environment with standard functions
@ 2016-07-03 21:20 Blanka Herono
0 siblings, 0 replies; 16+ messages in thread
From: Blanka Herono @ 2016-07-03 21:20 UTC (permalink / raw)
To: amirouche, guile-user
> Why do you think Sussman et al's. propagator don't solve OP problem?
I don't think Basa was saying this, exactly.
I think Basa meant using something like Matt Keeter's project:
https://www.mattkeeter.com/projects/ao/
https://www.mattkeeter.com/projects/ao/screencast.html [video]
(which is a functional CAD modeling system using C++/Guile) as a backend (graphical kernel) for a
propagator network which solves engineering constraints.
The reason Basa said it was a ways off is that the propagator code is in MIT Scheme. That would
mean either the code for the propagator would have to be ported or the code for Ao would be.
Ao itself is a nice project done in Guile, like OpenSCAD using Guile as a language. Another
valid issue Basa revisited is that there would probably need to be sandboxing or a declarative
language layer to use Ao for security with shared models. This issue was discussed a while back
on this mailing list.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2016-07-03 21:20 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-28 20:16 Transient environment with standard functions Matthew Keeter
2016-06-10 18:18 ` Basa Centro
2016-06-10 18:44 ` Matthew Keeter
2016-06-10 20:39 ` Basa Centro
2016-06-10 21:11 ` Taylan Ulrich Bayırlı/Kammer
2016-06-10 22:11 ` Basa Centro
2016-06-10 22:31 ` Matthew Keeter
2016-06-10 22:49 ` Mike Gran
2016-06-10 23:08 ` Taylan Ulrich Bayırlı/Kammer
2016-06-11 15:15 ` Basa Centro
2016-06-11 19:44 ` Matthew Keeter
2016-06-10 22:35 ` Chris Vine
-- strict thread matches above, loose matches on Subject: below --
2016-06-11 23:07 Basa Centro
2016-06-12 0:51 Basa Centro
2016-06-26 21:29 ` Amirouche Boubekki
2016-07-03 21:20 Blanka Herono
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).