[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Irb and Ruby Separation

Nicholas Van Weerdenburg

1/14/2005 8:55:00 PM

I've been wondering about why are irb and ruby separate programs.

Python combines the two concepts in its main executable, and I was
wondering if there was a benefit to separating them.

Thanks,
Nick
--
Nicholas Van Weerdenburg


9 Answers

Gennady

1/14/2005 8:59:00 PM

0

Nicholas Van Weerdenburg wrote:
> I've been wondering about why are irb and ruby separate programs.
>
> Python combines the two concepts in its main executable, and I was
> wondering if there was a benefit to separating them.
>
> Thanks,
> Nick

They are not. irb is a ruby program. Here's the content of
/usr/local/bin/irb:

#!/usr/local/bin/ruby
#
# irb.rb - intaractive ruby
# $Release Version: 0.7.3 $
# $Revision: 1.2 $
# $Date: 2002/11/19 02:00:18 $
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#

require "irb"

if __FILE__ == $0
IRB.start(__FILE__)
else
# check -e option
if /^-e$/ =~ $0
IRB.start(__FILE__)
else
IRB.setup(__FILE__)
end
end

Gennady.



Florian Gross

1/14/2005 9:13:00 PM

0

Nicholas Van Weerdenburg wrote:

> I've been wondering about why are irb and ruby separate programs.

The benefit is that IRB is a Ruby program, making it easier to patch it
or to do funky stuff. (Like I've done with the Breakpoint library.)

I think it is a good thing to get above the C level whenever you can.
There's a downside of course: IRB needs to re implement some of the
functionality that Ruby already has. (It needed to implement it's own
Lexer, for example, nowadays it could use Ripper instead, but it would
still need to find out whether an expression is already finished or not.)

Nicholas Van Weerdenburg

1/14/2005 9:16:00 PM

0

Thanks.

I guess my question might be better phrased "why doesn't running the
ruby interpreter with no input not default to interactive mode (irb)
such as with the python interpreter".

I'm mostly curious for no practical reason. Just wondering if there is
functionality or design benefits.

On Sat, 15 Jan 2005 05:59:13 +0900, Gennady Bystritksy <gfb@tonesoft.com> wrote:
> Nicholas Van Weerdenburg wrote:
> > I've been wondering about why are irb and ruby separate programs.
> >
> > Python combines the two concepts in its main executable, and I was
> > wondering if there was a benefit to separating them.
> >
> > Thanks,
> > Nick
>
> They are not. irb is a ruby program. Here's the content of
> /usr/local/bin/irb:
>
> #!/usr/local/bin/ruby
> #
> # irb.rb - intaractive ruby
> # $Release Version: 0.7.3 $
> # $Revision: 1.2 $
> # $Date: 2002/11/19 02:00:18 $
> # by Keiju ISHITSUKA(keiju@ishitsuka.com)
> #
>
> require "irb"
>
> if __FILE__ == $0
> IRB.start(__FILE__)
> else
> # check -e option
> if /^-e$/ =~ $0
> IRB.start(__FILE__)
> else
> IRB.setup(__FILE__)
> end
> end
>
> Gennady.
>
>

--
Nicholas Van Weerdenburg


Nikolai Weibull

1/14/2005 9:36:00 PM

0

* Nicholas Van Weerdenburg (Jan 14, 2005 22:20):
> I guess my question might be better phrased "why doesn't running the
> ruby interpreter with no input not default to interactive mode (irb)
> such as with the python interpreter".

It interprets stdin instead. irb is a completely separate project from
bin/ruby. It's much the same as the shell is separate from the kernel;
an idea that seems to have been foregone by the Python developers.
nikolai

--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


Dimitri Aivaliotis

1/14/2005 10:10:00 PM

0

On Sat, 15 Jan 2005 06:36:06 +0900, Nikolai Weibull
<mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:
> * Nicholas Van Weerdenburg (Jan 14, 2005 22:20):
> > I guess my question might be better phrased "why doesn't running the
> > ruby interpreter with no input not default to interactive mode (irb)
> > such as with the python interpreter".
>
> It interprets stdin instead. irb is a completely separate project from
> bin/ruby. It's much the same as the shell is separate from the kernel;
> an idea that seems to have been foregone by the Python developers.
> nikolai
>
Cool:

[shell prompt] ruby
puts "Hello, world!"
^D
Hello, world!
[shell prompt]

So, in effect it does essentially what's needed - just no shell-like
interface, or any of the other benefits of irb.

- Dimitri


nobu.nokada

1/15/2005 5:40:00 AM

0

Hi,

At Sat, 15 Jan 2005 06:15:33 +0900,
Nicholas Van Weerdenburg wrote in [ruby-talk:126498]:
> I guess my question might be better phrased "why doesn't running the
> ruby interpreter with no input not default to interactive mode (irb)
> such as with the python interpreter".
>
> I'm mostly curious for no practical reason. Just wondering if there is
> functionality or design benefits.

It's in the ToDo list.

* Built-in Interactive Ruby.


Index: ruby.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ruby.c,v
retrieving revision 1.94
diff -U2 -p -r1.94 ruby.c
--- ruby.c 24 Sep 2004 05:53:41 -0000 1.94
+++ ruby.c 15 Jan 2005 05:34:34 -0000
@@ -782,5 +782,15 @@ proc_options(argc, argv)
}
else if (strlen(script) == 1 && script[0] == '-') {
- load_stdin();
+ if (!do_check && !do_loop && isatty(0) && isatty(1) && isatty(2) &&
+ !NIL_P(rb_rescue2(rb_require, (VALUE)"irb",
+ (VALUE (*)())0, (VALUE)0,
+ rb_eLoadError, (VALUE)0))) {
+ require_libraries();
+ ruby_eval_tree = NEW_CALL(NEW_LIT(rb_const_get(rb_cObject, rb_intern("IRB"))),
+ rb_intern("start"), 0);
+ }
+ else {
+ load_stdin();
+ }
}
else {


--
Nobu Nakada


Csaba Henk

1/15/2005 12:13:00 PM

0

On 2005-01-15, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
> Hi,
>
> At Sat, 15 Jan 2005 06:15:33 +0900,
> Nicholas Van Weerdenburg wrote in [ruby-talk:126498]:
>> I guess my question might be better phrased "why doesn't running the
>> ruby interpreter with no input not default to interactive mode (irb)
>> such as with the python interpreter".
>>
>> I'm mostly curious for no practical reason. Just wondering if there is
>> functionality or design benefits.
>
> It's in the ToDo list.
>
> * Built-in Interactive Ruby.

I guess this transition mainly boils down to changing the parser/lexer
used in irb (written in ruby) to the one used within ruby itself, doesn't
it?

Csab

Nikolai Weibull

1/15/2005 12:48:00 PM

0

* Csaba Henk (Jan 15, 2005 13:40):
> > It's in the ToDo list.
> >
> > * Built-in Interactive Ruby.

> I guess this transition mainly boils down to changing the parser/lexer
> used in irb (written in ruby) to the one used within ruby itself,
> doesn't it?

Eh, the transition mainly boils down to the patch that was included,
right?
nikolai


--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}


Csaba Henk

1/15/2005 1:18:00 PM

0

On 2005-01-15, Nikolai Weibull <mailing-lists.ruby-talk@rawuncut.elitemail.org> wrote:

>> I guess this transition mainly boils down to changing the parser/lexer
>> used in irb (written in ruby) to the one used within ruby itself,
>> doesn't it?
>
> Eh, the transition mainly boils down to the patch that was included,
> right?

Uh, I tought that's just the top of the iceberg...

Csab