From: Phrogz Date: 2007-11-08T01:10:03+09:00 Subject: Re: Language Popularity - PHP vs Ruby? On Nov 7, 8:14 am, Vasyl Smirnov wrote: > On Nov 7, 1:11 pm, Alex Young wrote: > > > Am I wrong in thinking that mod_ruby runs all scripts in the same > > interpreter, so they all share a namespace? > > The following: > > page-a.rb > > #!/usr/local/bin/eruby > <% > class Foo > def bar > puts "Page A: Foo#bar
" > end > end > def baz > puts "Page A: baz
" > end > Foo.new.bar > baz > %> > > page-b.rb: > > #!/usr/local/bin/eruby > <% > class Foo > def bar > puts "Page B: Foo#bar
" > end > end > def baz > puts "Page B: baz
" > end > Foo.new.bar > baz > %> > > works just fine. Yes, it would, but that could be because each file runs over the other one. For example: C:\>type t1.rb class Foo def bar puts "Page A: Foo#bar
" end end def baz puts "Page A: baz
" end Foo.new.bar baz C:\>type t2.rb class Foo def bar puts "Page B: Foo#bar
" end end def baz puts "Page B: baz
" end Foo.new.bar baz C:\>irb irb(main):001:0> load 't1.rb' Page A: Foo#bar
Page A: baz
=> true irb(main):002:0> load 't2.rb' Page B: Foo#bar
Page B: baz
=> true irb(main):003:0> load 't1.rb' Page A: Foo#bar
Page A: baz
=> true Obviously that's all in the same namespace/interpreter, but you don't see a problem. Instead, try something like this: C:\>type t1.rb p @foo ||= 'page 1' C:\>type t2.rb p @foo ||= 'page 2' C:\>irb irb(main):001:0> load 't1.rb' "page 1" => true irb(main):002:0> load 't2.rb' "page 1" => true