Victor "Zverok" Shepelev wrote:
> Hello all.
> 
> During last several monthes I've worked on some library, using the latest
> ruby1.9. Now I want to release the library to community, but first I need to
> "backport" it.
> One small problem I've stumbled upon:
> 
> module Constants
>   TEST = 5
> end
> 
> class A
> end
> 
> a = A.new
> 
> a.instance_eval{
>   extend Constants
>   p TEST #<== here
> }
> 
> At the "here" string, ruby1.9 had printed "5", but ruby 1.8.5 raises
> NameError (uninitialized constant TEST).

module Constants
   TEST = 5
end

class A
end

a = A.new

m = Module.new
def m.const_missing k
   Constants.const_get(k) || super(k)
end

string_from_file = <<END
   TEST
END

test = m.module_eval %{
   a.instance_eval {
     #{string_from_file}
   }
}

p test # ==> 5

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407