Language Popularity - PHP vs Ruby?

You can more or less do that for rdoc because of the frames. Very

clunky, though.

firstly let me say, rdoc is great. parsing ruby is not an easy task and
the work that went into rdoc is tremendous, but, it seriously needs an
overhaul.

it uses constants to store templates in a non-standard format in such a
way that you cannot for instance load the same template twice in one
process w/o constant redefinition errors.

it is also quite difficult to write a template. it should all be erb, or
even better, easily pluggable modules so that haml and company can also
be used. actually, somebody already hacked this together and it is not a
big hack (http://coderepos.org/share/wiki/Resh\).

it should be easy to add things like syntax highlighted example code
snippets for instance, and custom navigation schemes, plain html pages,
etc...

just me 2 cents,
_c

···

--
Posted via http://www.ruby-forum.com/\.

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<br>"
  end
end
def baz
  puts "Page A: baz<br>"
end
Foo.new.bar
baz

C:\>type t2.rb
class Foo
  def bar
    puts "Page B: Foo#bar<br>"
  end
end
def baz
  puts "Page B: baz<br>"
end
Foo.new.bar
baz

C:\>irb
irb(main):001:0> load 't1.rb'
Page A: Foo#bar<br>
Page A: baz<br>
=> true

irb(main):002:0> load 't2.rb'
Page B: Foo#bar<br>
Page B: baz<br>
=> true

irb(main):003:0> load 't1.rb'
Page A: Foo#bar<br>
Page A: baz<br>
=> 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

···

On Nov 7, 8:14 am, Vasyl Smirnov <vasyl.smir...@gmail.com> wrote:

On Nov 7, 1:11 pm, Alex Young <a...@blackkettle.org> 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<br>"
  end
end
def baz
  puts "Page A: baz<br>"
end
Foo.new.bar
baz
%>

page-b.rb:

#!/usr/local/bin/eruby
<%
class Foo
  def bar
    puts "Page B: Foo#bar<br>"
  end
end
def baz
  puts "Page B: baz<br>"
end
Foo.new.bar
baz
%>

works just fine.

OK, here we go:

t1.rb:

#!/usr/local/bin/eruby
<%
p @foo ||= 'page 1'
%>

t2.rb:

#!/usr/local/bin/eruby
<%
p @foo ||= 'page 2'
%>

Result - works like a charm: t1 gives "page 1", t2 gives "page 2"
(in the browser window, of course).
No matter how many times and in what sequence I reload the pages.

···

On Nov 7, 6:10 pm, Phrogz <phr...@mac.com> wrote:

[cut]

Obviously that's all in the same namespace/interpreter, but you don't
see a problem. Instead, try something like this:

[cut]

Result - works like a charm: t1 gives "page 1", t2 gives "page 2"
(in the browser window, of course).
No matter how many times and in what sequence I reload the pages.

Repeating this test with a global variable $foo might be more
revealing though, as it is unclear in which context @foo is evaluated.

or

p defined?(Foo)
class Foo
end

Yep, you're right...

···

On Nov 7, 8:35 pm, tho_mica_l <micat...@gmail.com> wrote:

Repeating this test with a global variable $foo might be more
revealing though, as it is unclear in which context @foo is evaluated.

again, the latter form somehow does work :slight_smile:

defined.rb:

#!/usr/local/bin/eruby
<%
p defined?(Foo)
class Foo
end
p defined?(Foo)
%>

outputs << nil "constant" >> to the browser.

So maybe just the global vars are shared?

···

On Nov 7, 8:35 pm, tho_mica_l <micat...@gmail.com> wrote:

Repeating this test with a global variable $foo might be more
revealing though, as it is unclear in which context @foo is evaluated.

or

p defined?(Foo)
class Foo
end