From: matz@... (Yukihiro Matsumoto) Date: 2003-02-02T23:40:26+09:00 Subject: Re: Local variables & blocks Hi, In message "Re: Local variables & blocks" on 03/02/02, Brian Candler writes: |On Sun, Feb 02, 2003 at 01:50:05PM +0100, ts wrote: |> What do you do with Thread and Proc which *need* block local variables ? | |Hmm. ISTM that if this is a problem, it will affect Matz's [63100] as well. No. Unlike yours, mine still has sort of block local variabls. |I just re-read the Pickaxe section on threads, and yes I agree - and I also |think it's a mess. When you assign to 'x' within a block, it has two |entirely different behaviours, depending on whether 'x' was in existence |previously or not. I agree with you. I was insane when I designed this rule. That's why I propose the change. But I don't think we can just drop block local variables like yours, since we have Proc (some kind of anonymous function), we need some kind of local variables of their own. |Now, as for Procs, I haven't used them much but I suppose the same sort of |thing applies: | | i = 1 | ... | a = Proc.new { |x| i = x+x; i } # 'i' is some intermediate variable Unfortunately, this doesn't work for closures. In a plain words, global variables (from the viewpoint of a Proc) can not always replace local variables. matz.