[MacRuby-devel] Concurrency bug in ControlTower

Charles Oliver Nutter headius at headius.com
Sat Jan 29 14:46:59 PST 2011


On Wed, Jan 26, 2011 at 4:50 PM, Laurent Sansonetti
<lsansonetti at apple.com> wrote:
> No, only locals and dynamic (block) variables.
> To be honest I always disliked this semantic change too. I think it was a
> mistake to add it. It will probably be reverted for 1.0.

I started to try to implement it, and it's not easy. I would need to
cascade all the way up the containing scopes, cloning each one. It's
very messy.

I would have no objections to this behavior going away.

What if instead of e.g. async, you had the following form:

queue.async(a, b) {|a, b| ... }

Because 1.9 forces variables in the block's argument list to be local
to the block, this would avoid the sharing of variables completely.

This would work with anything proc-like as well:

job = ->(a, b) { ... } # block-local a and b
queue.async(a, b, &job) # outer scope's a and b

Of course you might want to rename them in the block, to avoid
confusion, but this neatly does what "tap" did in my suggested fix
(and I don't know why I didn't think of it sooner).

- Charlie


More information about the MacRuby-devel mailing list