From: nobu.nokada@... Date: 2002-12-18T19:44:13+09:00 Subject: Re: $SAFE block? Hi, At Wed, 18 Dec 2002 18:59:21 +0900, Tim Bates wrote: > Once $SAFE is set to a certain level, it's not possible to lower it again. As > far as I know, the only way to execute some code at a high $SAFE level and > then return to a lower one is like this: > > thread = Thread.new { > $SAFE = 4 > # .. do code > } > thread.join > > Which is messy to say the least. Why not have something like: > > Kernel#safe(anInteger) { block } 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 -- Nobu Nakada