Shalev NessAiver wrote:
> Yes, I know ruby already has irb, but I have a friend who keeps
> engaging me in these python vs. ruby wars and he recently submitted
> the challenge to me to
>
> "Write a fully featured REPL for ruby in 70 lines or less.
> Furthermore, it can't be written in ruby."

Either:

15:08:08 [source]: ruby -r irb -e 'IRB.start'
irb(main):001:0> 1+10
=> 11
irb(main):002:0> exit

Or:

16:19:51 [source]: ruby -e '$bnd = binding; while (line=gets); exit if
/exit/ =~ line; p eval(line,$bnd); end'
1+10
11
a="foo"
"foo"
a << "bar"
"foobar"
a
"foobar"
exit
16:20:17 [source]:

You see, it's a one liner - either way. :-)

Admittedly the second one doesn't cope with multiline input.  But I guess
it doesn't take too much to add that.

> I was thinking of using Ruby/C but I've never wrote anything like
> this before.  Is their any tips anyone can give me so I can uphold
> ruby's honor?

Dunno whether you actually have to enter this competition: if he doesn't
like Ruby, let him continue using Python...

Kind regards

    robert