Email list hosting service & mailing list manager

Comments on SRFI-39 shivers@xxxxxx (26 Jan 2003 08:45 UTC)
Re: Comments on SRFI-39 Matthew Flatt (26 Jan 2003 14:10 UTC)
Re: Comments on SRFI-39 sperber@xxxxxx (26 Jan 2003 15:38 UTC)
Re: Comments on SRFI-39 Richard Kelsey (11 Feb 2003 15:58 UTC)
Re: Comments on SRFI-39 bear (11 Feb 2003 16:16 UTC)
Re: Comments on SRFI-39 Richard Kelsey (11 Feb 2003 16:56 UTC)
Re: Comments on SRFI-39 Marc Feeley (13 Feb 2003 01:38 UTC)
Re: Comments on SRFI-39 Richard Kelsey (13 Feb 2003 02:30 UTC)
Re: Comments on SRFI-39 sperber@xxxxxx (13 Feb 2003 12:47 UTC)

Re: Comments on SRFI-39 Richard Kelsey 11 Feb 2003 15:57 UTC

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
nesting?

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
following:

  (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
the DYNAMIC-WIND?

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.

                                          -Richard