chicken-users
[Top][All Lists]
Advanced

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

Multiple environments


From: Diogo Behrens
Subject: Multiple environments
Date: Fri, 14 Jun 2024 09:36:54 +0200

Dear mailing list,

I’m looking for an elegant way how to manage multiple environments (global 
bindings) to build a concurrency simulator. The input of my simulator is the 
number of actors/coroutines/etc. I would like to have fully separate 
environments for these coroutines, so they can mutate variables with same name 
and won’t affect each other. The communication between each actor is not done 
via shared variables. 

Let’s say the coroutines would do something like:

```
(Spawn-coroutine
  (Lambda ()
     (Do-something)
     (Set! X (some-random-thing))
     (Yield)
     (Do-something-else)
     (Print X) ; the random thing of *this* coroutine
     (Yield)))
```

(Sorry for the unformatted code, my email client is trying to be clever)

I know I could use variables in the lambda scope, but I would prefer to avoid 
restricting the actors implementation.

I have a prototype in Racket, where I use make-base-namespace to create 
namespaces for each actor. I can then call eval with the lambda as first 
argument and the mutable namespace as second.

Would somebody in the mailing list have a suggestion how to handle this in an 
elegant way in CHICKEN?

Thank you.

Best,
-Diogo



reply via email to

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