Hi,

At Wed, 26 May 2004 06:28:44 +0900,
Ara.T.Howard wrote in [ruby-talk:101411]:
> if you like dangerous code, you might try something __like__ this:
> 
>   ~ > cat a.rb
>   class Rule
>     def initialize rule; @rule = rule.to_str; end
> 
>     def apply? obj
>       safe = $SAFE
>       thread = nil
>       begin
>         thread =
>           Thread.new(obj) do |obj|
>             $SAFE = 12
>             obj.instance_eval @rule
>           end
>         thread.join
>       ensure
>         $SAFE = safe
>       end
>       thread.value
>     end

You don't need save $SAFE, which is always thread local.  And,
Proc also preserves its $SAFE value.  Though this was an
unofficial feature in 1.6, guaranteed from 1.8.

-- 
Nobu Nakada