# Ruby interpreter written in ruby

**URL:** <https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607>\
**Category:** ruby-talk\
**Created:** [8 February 2009 09:45 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607 "2009-02-08T09:45:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catsquotl](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@Catsquotl](https://rubytalk.org/u/Catsquotl)\
**Post date:** [8 February 2009 09:45 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/1 "2009-02-08T09:45:16Z")

</div>

Hi there,

I am new to programming and ruby.. Trying to read through the pickaxe and do the exercises on Sphere Online Judge.  
I was wondering is there a ruby written ruby interpreter available? somehow i`d like to be able to read the interpreter source.

greetz Cat

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [8 February 2009 09:57 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/2 "2009-02-08T09:57:14Z")

</div>

no, not 100% (yet) at least. the rubinius project is farthest along in that effort.

&nbsp;&nbsp;&nbsp;[http://rubini.us/](http://rubini.us/)

the doco on that site is... well... not good. Just download the source and poke around. There is a fair amount in C++ still (last I looked) but a lot more pure ruby code than available in MRI or any other ruby impl project (last I looked).

> **···**
>
> On Feb 8, 2009, at 01:45 , Eelco wrote:
> 
> > I was wondering is there a ruby written ruby interpreter available? somehow i`d like to be able to read the interpreter source.

---

<div class="post-metadata">

**Author:** ![Dylan\_Evans](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Dylan\_Evans](https://rubytalk.org/u/Dylan_Evans)\
**Post date:** [8 February 2009 11:40 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/3 "2009-02-08T11:40:21Z")

</div>

It seems to me that would be pointless, since it would require another  
interpreter to function. Of course the other alternative would be to write a  
ruby compiler which would be awkward in a dynamic language. Of course if it  
wasn't actually compiled then you would have the overhead of interpreting a  
stack of ruby. Why would you want a ruby interpreter written in ruby?

> **···**
>
> On Sun, Feb 8, 2009 at 7:45 PM, Eelco \<catsquotl@gmail.com\> wrote:
> 
> > Hi there,
> > 
> > I am new to programming and ruby.. Trying to read through the pickaxe and  
> > do the exercises on Sphere Online Judge.  
> > I was wondering is there a ruby written ruby interpreter available? somehow  
> > i`d like to be able to read the interpreter source.
> > 
> > greetz Cat
> 
> --  
> The UNIX system has a command, nice ... in order to be nice to the other  
> users. Nobody ever uses it." - Andrew S. Tanenbaum

---

<div class="post-metadata">

**Author:** ![Catsquotl](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@Catsquotl](https://rubytalk.org/u/Catsquotl)\
**Post date:** [8 February 2009 12:14 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/4 "2009-02-08T12:14:11Z")

</div>

Dylan Evans schreef:

> **···**
>
> > On Sun, Feb 8, 2009 at 7:45 PM, Eelco \<catsquotl@gmail.com\> wrote:
> > 
> > > Hi there,
> > > 
> > > I am new to programming and ruby.. Trying to read through the pickaxe and  
> > > do the exercises on Sphere Online Judge.  
> > > I was wondering is there a ruby written ruby interpreter available? somehow  
> > > i`d like to be able to read the interpreter source.
> > > 
> > > greetz Cat
> > 
> > It seems to me that would be pointless, since it would require another  
> > interpreter to function. Of course the other alternative would be to write a  
> > ruby compiler which would be awkward in a dynamic language. Of course if it  
> > wasn't actually compiled then you would have the overhead of interpreting a  
> > stack of ruby. Why would you want a ruby interpreter written in ruby?
> 
> That makes sense......  
> I wasn`t thinking about the why or what..  
> Just as this is the first language i am trying to understand i thought i could learn a lot by reading the code  
> As C is jibberish to me..
> 
> Eelco

---

<div class="post-metadata">

**Author:** ![Julian\_Leviston](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Julian\_Leviston](https://rubytalk.org/u/Julian_Leviston)\
**Post date:** [8 February 2009 14:21 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/5 "2009-02-08T14:21:37Z")

</div>

Smalltalk is written in itself. It's quite useful! You can understand a lot about a language if it has such a high level of self-describingness. Rubinius is such a project.

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Learn rails: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

> **···**
>
> On 08/02/2009, at 10:40 PM, Dylan Evans \<dylan.star@gmail.com\> wrote:
> 
> > On Sun, Feb 8, 2009 at 7:45 PM, Eelco \<catsquotl@gmail.com\> wrote:
> > 
> > > Hi there,
> > > 
> > > I am new to programming and ruby.. Trying to read through the pickaxe and  
> > > do the exercises on Sphere Online Judge.  
> > > I was wondering is there a ruby written ruby interpreter available? somehow  
> > > i`d like to be able to read the interpreter source.
> > > 
> > > greetz Cat
> > 
> > It seems to me that would be pointless, since it would require another  
> > interpreter to function. Of course the other alternative would be to write a  
> > ruby compiler which would be awkward in a dynamic language. Of course if it  
> > wasn't actually compiled then you would have the overhead of interpreting a  
> > stack of ruby. Why would you want a ruby interpreter written in ruby?
> > 
> > --  
> > The UNIX system has a command, nice ... in order to be nice to the other  
> > users. Nobody ever uses it." - Andrew S. Tanenbaum

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [8 February 2009 21:55 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/6 "2009-02-08T21:55:54Z")

</div>

smalltalk (squeak, at the very least), many lisps/schemes, factor, every language designed by wirth... yeah. must be pointless. 😛

> **···**
>
> On Feb 8, 2009, at 03:40 , Dylan Evans wrote:
> 
> > It seems to me that would be pointless, since it would require another  
> > interpreter to function. Of course the other alternative would be to write a  
> > ruby compiler which would be awkward in a dynamic language. Of course if it  
> > wasn't actually compiled then you would have the overhead of interpreting a  
> > stack of ruby. Why would you want a ruby interpreter written in ruby?

---

<div class="post-metadata">

**Author:** ![John\_Carter](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@John\_Carter](https://rubytalk.org/u/John_Carter)\
**Post date:** [8 February 2009 22:42 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/7 "2009-02-08T22:42:31Z")

</div>

Hokay, so this is at the trivial "HEY! You Cheated!!" level... but  
it's still useful...

ri 'Kernel#eval'  
------------------------------------------------------------ Kernel#eval  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eval(string [, binding [, filename [,lineno]]]) =\> obj

> **···**
>
> On Sun, 8 Feb 2009, Dylan Evans wrote:
> 
> > > I was wondering is there a ruby written ruby interpreter available? somehow  
> > > i`d like to be able to read the interpreter source.
> 
> ------------------------------------------------------------------------  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Evaluates the Ruby expression(s) in \_string\_. If \_binding\_ is  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;given, the evaluation is performed in its context. The binding may  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;be a +Binding+ object or a +Proc+ object. If the optional  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\_filename\_ and \_lineno\_ parameters are present, they will be used  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when reporting syntax errors.
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def getBinding(str)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return binding  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str = "hello"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eval "str + ' Fred'" #=\> "hello Fred"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eval "str + ' Fred'", getBinding("bye") #=\> "bye Fred"
> 
> > Why would you want a ruby interpreter written in ruby?
> 
> Actually the original poster asked a very intelligent question.
> 
> Why would you want such a thing?
> 
> It's a \_very\_ effective measure of the simplicity and expressiveness  
> combined of the language.
> 
> For example, here is a minimal (non-trivial) Joy0 interpeter written  
> in Joy0 that will interpret itself.  
> Source [http://www.latrobe.edu.au/philosophy/phimvt/joy/jp-joyjoy.html](http://www.latrobe.edu.au/philosophy/phimvt/joy/jp-joyjoy.html)
> 
> joy0 ==  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[[[ joy0 body joy0]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[pop pop pop]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cons pop cons]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[opcase pop opcase]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[body pop body]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[i pop joy0]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[step pop [joy0] cons step ]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cons i] ]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opcase  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i ]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;step
> 
> Yup. That was it. All of it.
> 
> Says something very very powerful about the simplicity of the Joy  
> language.
> 
> I'll admit I learnt several things about the language when I read that  
> close enough to understand it.
> 
> I bet you'd have a good few "Aha!" moments if you could do the same  
> with Ruby.
> 
> Conversely, if you could strip Ruby to a Ruby0 essence in which you  
> could easily write a ruby0 in ruby0 interpreter... you'd learn what  
> was the essence of the language and what was sugar.
> 
> John Carter Phone : (64)(3) 358 6639  
> Tait Electronics Fax : (64)(3) 359 4632  
> PO Box 1645 Christchurch Email : john.carter@tait.co.nz  
> New Zealand

---

<div class="post-metadata">

**Author:** ![Tim\_Hunter4](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@Tim\_Hunter4](https://rubytalk.org/u/Tim_Hunter4)\
**Post date:** [8 February 2009 13:26 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/8 "2009-02-08T13:26:02Z")

</div>

Eelco wrote:

> I wasn`t thinking about the why or what..  
> Just as this is the first language i am trying to understand i thought i could learn a lot by reading the code

There's a huge amount of very good Ruby code out there in Ruby libraries and applications. Rails, Rake, RubyGems. All written in Ruby.

Also take a look at the past Ruby quizzes (rubyquiz.com)

> **···**
>
> --  
> RMagick: [http://rmagick.rubyforge.org/](http://rmagick.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![Dylan\_Evans](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Dylan\_Evans](https://rubytalk.org/u/Dylan_Evans)\
**Post date:** [9 February 2009 01:51 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/9 "2009-02-09T01:51:33Z")

</div>

kinda cool, and the lisps use either a bootstrap implementation or a  
translator.I was just thinking of a plain ruby interpreter entirely in ruby,  
which really would be pointless.  
Of course new languages written in interpreted languages can be good  
prototypes.

> **···**
>
> On Mon, Feb 9, 2009 at 7:55 AM, Ryan Davis \<ryand-ruby@zenspider.com\> wrote:
> 
> > On Feb 8, 2009, at 03:40 , Dylan Evans wrote:
> > 
> > It seems to me that would be pointless, since it would require another
> > 
> > > interpreter to function. Of course the other alternative would be to write  
> > > a  
> > > ruby compiler which would be awkward in a dynamic language. Of course if  
> > > it  
> > > wasn't actually compiled then you would have the overhead of interpreting  
> > > a  
> > > stack of ruby. Why would you want a ruby interpreter written in ruby?
> > 
> > smalltalk (squeak, at the very least), many lisps/schemes, factor, every  
> > language designed by wirth... yeah. must be pointless. 😛
> > 
> > I see that squeak uses a C translator for it's implementation which is
> 
> --  
> The UNIX system has a command, nice ... in order to be nice to the other  
> users. Nobody ever uses it." - Andrew S. Tanenbaum

---

<div class="post-metadata">

**Author:** ![Julian\_Leviston](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Julian\_Leviston](https://rubytalk.org/u/Julian_Leviston)\
**Post date:** [9 February 2009 02:50 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/10 "2009-02-09T02:50:10Z")

</div>

I don't think a measure such as that is useful for anything much. IMHO you'd want a language written in itself so you could understand it better at a lower level: pedagogy.

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Learn rails: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

> **···**
>
> On 09/02/2009, at 9:42 AM, John Carter \<john.carter@tait.co.nz\> wrote:
> 
> > On Sun, 8 Feb 2009, Dylan Evans wrote:
> > 
> > > > I was wondering is there a ruby written ruby interpreter available? somehow  
> > > > i`d like to be able to read the interpreter source.
> > 
> > Hokay, so this is at the trivial "HEY! You Cheated!!" level... but  
> > it's still useful...
> > 
> > ri 'Kernel#eval'  
> > ------------------------------------------------------------ Kernel#eval  
> > &nbsp;&nbsp;&nbsp;&nbsp;eval(string [, binding [, filename [,lineno]]]) =\> obj  
> > ------------------------------------------------------------------------  
> > &nbsp;&nbsp;&nbsp;&nbsp;Evaluates the Ruby expression(s) in \_string\_. If \_binding\_ is  
> > &nbsp;&nbsp;&nbsp;&nbsp;given, the evaluation is performed in its context. The binding may  
> > &nbsp;&nbsp;&nbsp;&nbsp;be a +Binding+ object or a +Proc+ object. If the optional  
> > &nbsp;&nbsp;&nbsp;&nbsp;\_filename\_ and \_lineno\_ parameters are present, they will be used  
> > &nbsp;&nbsp;&nbsp;&nbsp;when reporting syntax errors.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def getBinding(str)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return binding  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str = "hello"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eval "str + ' Fred'" #=\> "hello Fred"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eval "str + ' Fred'", getBinding("bye") #=\> "bye Fred"
> > 
> > > Why would you want a ruby interpreter written in ruby?
> > 
> > Actually the original poster asked a very intelligent question.
> > 
> > Why would you want such a thing?
> > 
> > It's a \_very\_ effective measure of the simplicity and expressiveness  
> > combined of the language.
> > 
> > For example, here is a minimal (non-trivial) Joy0 interpeter written  
> > in Joy0 that will interpret itself.  
> > Source [http://www.latrobe.edu.au/philosophy/phimvt/joy/jp-joyjoy.html](http://www.latrobe.edu.au/philosophy/phimvt/joy/jp-joyjoy.html)
> > 
> > joy0 ==  
> > &nbsp;&nbsp;&nbsp;[[[ joy0 body joy0]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[pop pop pop]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cons pop cons]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[opcase pop opcase]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[body pop body]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[i pop joy0]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[step pop [joy0] cons step ]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cons i] ]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opcase  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i ]  
> > &nbsp;&nbsp;&nbsp;step
> > 
> > Yup. That was it. All of it.
> > 
> > Says something very very powerful about the simplicity of the Joy  
> > language.
> > 
> > I'll admit I learnt several things about the language when I read that  
> > close enough to understand it.
> > 
> > I bet you'd have a good few "Aha!" moments if you could do the same  
> > with Ruby.
> > 
> > Conversely, if you could strip Ruby to a Ruby0 essence in which you  
> > could easily write a ruby0 in ruby0 interpreter... you'd learn what  
> > was the essence of the language and what was sugar.
> > 
> > John Carter Phone : (64)(3) 358 6639  
> > Tait Electronics Fax : (64)(3) 359 4632  
> > PO Box 1645 Christchurch Email : john.carter@tait.co.nz  
> > New Zealand

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [9 February 2009 06:54 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/11 "2009-02-09T06:54:27Z")

</div>

there you go using that word ("pointless") again... As someone who worked on smalltalk for many years and was working on metaruby before I was professionally working on rubinius, I have to highly disagree. I'm gonna leave it at that tho.

> **···**
>
> On Feb 8, 2009, at 17:51 , Dylan Evans wrote:
> 
> > I see that squeak uses a C translator for it's implementation which is  
> > kinda cool, and the lisps use either a bootstrap implementation or a  
> > translator.I was just thinking of a plain ruby interpreter entirely in ruby,  
> > which really would be pointless.

---

<div class="post-metadata">

**Author:** ![Dylan\_Evans](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Dylan\_Evans](https://rubytalk.org/u/Dylan_Evans)\
**Post date:** [9 February 2009 08:16 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/12 "2009-02-09T08:16:25Z")

</div>

to a ruby interpreter written in ruby yes, but then this interpreter is  
interpreted by for example rubinius, or jruby, or any other ruby  
interpreter. Ok as an exercise that might be an interesting project, or  
perhaps it could be useful for some sort of sandboxing, but what about day  
to day use? What function would that serve? If you wanted you could keep  
stacking interpreters on top of each other until you had an expensive 386.

> **···**
>
> On Mon, Feb 9, 2009 at 4:54 PM, Ryan Davis \<ryand-ruby@zenspider.com\> wrote:
> 
> > On Feb 8, 2009, at 17:51 , Dylan Evans wrote:
> > 
> > I see that squeak uses a C translator for it's implementation which is
> > 
> > > kinda cool, and the lisps use either a bootstrap implementation or a  
> > > translator.I was just thinking of a plain ruby interpreter entirely in  
> > > ruby,  
> > > which really would be pointless.
> > 
> > there you go using that word ("pointless") again... As someone who worked  
> > on smalltalk for many years and was working on metaruby before I was  
> > professionally working on rubinius, I have to highly disagree. I'm gonna  
> > leave it at that tho.
> > 
> > Seriously? You understand what i'm saying is pointless right? I'm referring
> 
> --  
> The UNIX system has a command, nice ... in order to be nice to the other  
> users. Nobody ever uses it." - Andrew S. Tanenbaum

---

<div class="post-metadata">

**Author:** ![John\_Carter](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@John\_Carter](https://rubytalk.org/u/John_Carter)\
**Post date:** [11 February 2009 00:45 UTC](https://rubytalk.org/t/ruby-interpreter-written-in-ruby/51607/13 "2009-02-11T00:45:43Z")

</div>

I strongly agree with you, what you have been doing \_is\_ very  
interesting and valuable.

Which leads to some questions I have for you... you probably don't  
have the answers to them, but your thoughts about what the answers may  
be should be interesting.

1) The "lisp in lisp" / "joy in joy" / ... interpreters I have seen have  
sort of glossed over the lexical / parsing issue by assuming that they  
are interpreting an already internalised representation of the  
program.

This is part of the classic basic data representation === the basic program  
representation ambiguity of these languages.

We can pretty much do this in Ruby too... A ruby program can be  
represented as an Array of Symbols, Numbers and Strings.

So assuming at least a lexical analyser that will chew on Ruby program  
text and spit out an Array of Symbols, Numbers and Strings....

Q1a) What would be the Ruby0 language? ie. What is the smallest subset  
&nbsp;&nbsp;of Ruby that could be used to write a self-interpreting interpreter.

Q1b) Could there be a way of hijacking the Ruby internal lexer to  
cough up such an Array of Objects?

Q1c) What would be the RubyLex0 definition? (The simplist subset of  
Ruby lexical analysis that could be used as a front end to a Ruby0  
interpreter)

2) A major gotcha is Regular Expressions are a "language within a language".

2a) It would be a fun thing to do to create a Ruby Regex to Ruby  
compiler - and then extend the semantics hugely.

2b) What would be the simplist Ruby0 in Ruby0 definition \_including\_  
the lexical analysis from text?

John Carter Phone : (64)(3) 358 6639  
Tait Electronics Fax : (64)(3) 359 4632  
PO Box 1645 Christchurch Email : john.carter@tait.co.nz  
New Zealand

> **···**
>
> On Mon, 9 Feb 2009, Ryan Davis wrote:
> 
> > As someone who worked on smalltalk for many years and was working on  
> > metaruby before I was professionally working on rubinius, I have to  
> > highly disagree.
