Forgive my newbness, but how would one use/compile that code?
The instructions for creating an extension (using extconf.rb) seems  
to be geared towards
compiling Ruby-C classes... how I just compile and run this code?

-Thanks
Shalev


On Aug 16, 2005, at 2:08 PM, Ben Giddings wrote:

> On Monday 15 August 2005 10:11, 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."
>>
>
> I guess he means write it in C then?
>
> Maybe I misunderstand the problem, but here's one that's exactly 70  
> lines:
>
> /**
>  * \file repl.c
>  *
>  * \author Ben Giddings <bg-ruby / infofiend.com>
>  * Copyright (C) 2005, Ben Giddings
>  *
>  */
>
> #include <stdio.h>
> #include <ruby.h>
>
> #define INPUT_SIZE 0x100
>
> int main(int argc, char **argv)
> {
>     char input_buff[INPUT_SIZE];
>     int error;
>
>     ruby_init();
>     ruby_script("repl"); /* ? */
>
>     while (1)
>     {
>         memset(input_buff, '\0', sizeof(input_buff));
>         printf("repl> "); // no newline on purpose
>         fgets(input_buff, INPUT_SIZE-1, stdin);
>         if (0 == strncmp("quit", input_buff, 4))
>         {
>             break;
>         }
>         rb_p(rb_eval_string_protect(input_buff, &error));
>         if (error)
>         {
>             rb_p(ruby_errinfo);
>         }
>     }
>
>     return error;
> }
>
> /*
> Hmm, line 42.  Guess I gotta add another 28 lines to get to 70
>
> He addresses a man standing behind a desk marked "Complaints".
> C: I wish to complain, British-Railways Person.
> Attendant: I DON'T HAVE TO DO THIS JOB, YOU KNOW!!!
> C: I beg your pardon...?
> A: I'm a qualified brain surgeon! I only do this job because I like  
> being
> my own boss!
> C: Excuse me, this is irrelevant, isn't it?
> A: Yeah, well it's not easy to pad these python files out to 200  
> lines, you
> know.
> C: Well, I wish to complain. I got on the Bolton train and found  
> myself
> deposited here in Ipswitch.
> A: No, this is Bolton.
> C: (to the camera) The pet shop man's brother was lying!!
> A: Can't blame British Rail for that.
> C: In that case, I shall return to the pet shop!
> He does.
> C: I understand this IS Bolton.
> O: (still with the fake mustache) Yes?
> C: You told me it was Ipswitch!
> O: ...It was a pun.
> C: (pause) A PUN?!?
> O: No, no...not a pun...What's that thing that spells the same  
> backwards as
> forwards?
> C: (Long pause) A palindrome...?
> O: Yeah, that's it!
> C: It's not a palindrome! The palindrome of "Bolton" would be  
> "Notlob"!! It
> don't work!!
> O: Well, what do you want?
> C: I'm not prepared to pursue my line of inquiry any longer as I  
> think this
> is getting too silly!
> Sergeant-Major: Quite agree, quite agree, too silly, far too silly...
> */
>
>