> You could even do:
>
> =A0class Thread
> =A0 =A0def self.inherit
> =A0 =A0 =A0parent =3D Thread.current
> =A0 =A0 =A0new do
> =A0 =A0 =A0 =A0parent.keys.each do |key|
> =A0 =A0 =A0 =A0 =A0next if key =3D~ /^__/
> =A0 =A0 =A0 =A0 =A0Thread.current[key] =3D parent[key]
> =A0 =A0 =A0 =A0end
> =A0 =A0 =A0 =A0yield
> =A0 =A0 =A0end
> =A0 =A0end
> =A0end
>
> Which would be used like Thread.new, but automatically copy the parent's =
thread-locals to the new thread.


It would seem that something like that is probably necessary to
preserve sanity among thread's and fibers.

Another option would be to allow for Fiber#[] to work.

That would be less surprising to me than having Thread.current[]
magically be assigning to two different places, depending on context.
But they'd both require some shenanigens, as if you wanted to allow
library users to write "blind" code you'd have to remap
Thread.current[] to use Fiber.current[] when called within a running
fiber.  Still more code to write but seems more explicit to me and
less surprising.
Just thinking out loud.
=3Dr