chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] srfi-18 threads question


From: John Cowan
Subject: Re: [Chicken-users] srfi-18 threads question
Date: Wed, 21 Sep 2016 17:12:59 -0400


On Wed, Sep 21, 2016 at 4:53 PM, <address@hidden> wrote:

;; Why does the mutation of a simple global in a thread become visible to the main thread, but the mutation of global parameter does not?

In general, parameters are designed to be per-thread rather than shared.  If they weren't, the parameter wouldn't reliably maintain its value throughout the dynamic scope of a parameterize form.  So when you attempt to mutate a parameter from another thread, you are mutating a copy.

Specifically, a parameter that has been bound with parameterize is always
per-thread. As you can see by looking at SRFI 39's rationale, unbound parameters can behave differently in different implementations.  Chicken chooses to make them per-thread in all cases: parameters are just elements of a hidden vector that is copied when a new thread is forked (which means it's expensive to have millions of parameter objects).

reply via email to

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