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

Re: Comments on SRFI-39

This page is part of the web mail archives of SRFI 39 from before July 7th, 2015. The new archives for SRFI 39 contain all messages, not just those from before July 7th, 2015.

Olin wrote:

  Spawning a thread, calling a function -- it's a dynamic nesting. 

The whole point to spawning a thread is that it isn't a dynamic
nesting.  If you wanted dynamic nesting you wouldn't spawn a thread,
you would just call the thunk.  The new thread's execution may happen
before the spawning call returns or it may happen after the spawning
thread has finished or the two may be interleaved.  Where's the

If threads inherit dynamic bindings but DYNAMIC-WIND thunks are not
called when switching between threads (as they aren't in SRFI 18),
you get two different notions of dynamic nesting.  Consider the
  (let ((param (make-parameter (lambda () 'initial)))
        (x 'out))
    (parameterize ((param (lambda () x)))
      (dynamic-wind (lambda () (set! x 'in))
                    (spawn (lambda ()
                             (display ((param)))))
                    (lambda () (set! x 'out)))))

If you use SRFI 18 and SRFI 39 then spawning a thread is a dynamic
nesting but running one is not and this prints IN or OUT.  This makes
no sense to me.  Why does the new thread see the PARAMETERIZE but not

If you want spawning a thread to be a dynamic nesting then you should
make running one also be dynamic.  This gives you parameter inheritance,
you run the DYNAMIC-WIND thunks on thead switches , and the code above
prints IN.  If threads do not have any dynamic nesting then you don't
have parameter inheritance, don't run the thunks, and it prints INITIAL.
Both of these make sense, but the second one seems more useful.