From: nobu.nokada@... Date: 2002-12-18T20:06:56+09:00 Subject: Re: $SAFE block? Hi, At Wed, 18 Dec 2002 19:48:49 +0900, Tim Bates wrote: > > module Kernel > > def safe(level) > > proc {$SAFE = level; yield}.call > > end > > end > > > > p Thread.current.safe_level # => 0 > > p safe(4) { Thread.current.safe_level } # => 4 > > p Thread.current.safe_level # => 0 > > Much better! It doesn't use more threads, which is what I was looking for. I > didn't realise Proc reset $SAFE at its end. Thanks a lot. And thanks to the > person who submitted the other solution, even if it wasn't what I wanted. Proc doesn't reset $SAFE, but has each own safe level. This behavior was pointed out by nagai@ai.kyutech.ac.jp at [ruby-dev:17220], and admitted as feature. -- Nobu Nakada