From: Conrad Schneiker Date: 2001-05-04T04:02:38+09:00 Subject: [ruby-talk:14598] Re: Arggg Bitten by the block var scope feature!!! # On Thu, 3 May 2001, Wayne Scott wrote: # # > #simplified for this discussion # > def fetch(arg2) # > # cheesy block to flush cache if it has gotten too big # > if @cache.length > 200 # > # one pass at flushing cache # > @cache.dup.each do |arg2, file| ## (1) # > file.flush # > @cache.delete arg2 # > end # > end # > unless @cache[arg2] ## (2) # > @cache[arg2] = @cl.new(@arg1, arg2) # > end # > @cache[arg2] # > end # # I don't know if the behavior should change but I think it should at # least issue a warning if there is reuse like this. I think this is an important suggestion. Answers such as: 1) I should have known better. 2) You should have known better. 3) Here is a way around this. 4) There is (or soon will be) a better feature to use. 5) Once you know Ruby better, this won't be a problem for you. are all true to some degree, but are somewhat beside the point of accident prevention in the cases that people are caught unawares. Some of the more fair-minded critiques of Ruby that I've seen could be construed as saying that "Ruby is an easy language, except ..., but ..., and so on." This is a chance to remove one of those "excepts" and "buts". Maybe a "last resort" "extra cautious" warning level is needed to deal with things such as this, so that people can habitually run with -w without being overwhelmed with false alarms about issues they know about or have otherwise dealt with. Conrad Schneiker (This note is unofficial and subject to improvement without notice.)