Re:JRuby 9000 released
by jrochkind1 on Wednesday July 22, 2015 @07:42PM
(#9933094)
Huh, if the local various was only scoped to the closure block, and not above it, I would never expect it to be shared. I would think "avoid using closure state" means exactly that, use only local variables scoped no higher than the closure block itself. (It's true this can sometimes be difficult to ensure in ruby; block local variables can help).
Do I understand things right, or am I wrong here?
I guess the question is where the regexp special vars are scoped to though, I see how that's not entirely clear.
Re:JRuby 9000 released
by headius on Wednesday July 22, 2015 @09:54PM
(#9933545)
You're largely right. The problem is that $~ (and related vars) and $_ are scoped to the nearest method body. If they were scoped to the closure itself, there'd be no problem.
Do I understand things right, or am I wrong here?
I guess the question is where the regexp special vars are scoped to though, I see how that's not entirely clear.