From: Julian Leviston Date: 2009-02-09T11:50:10+09:00 Subject: Re: ruby interpreter written in ruby.. 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/ Learn rails: http://sensei.zenunit.com/ On 09/02/2009, at 9:42 AM, John Carter 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 > eval(string [, binding [, filename [,lineno]]]) => obj > --- > --------------------------------------------------------------------- > Evaluates the Ruby expression(s) in _string_. If _binding_ is > given, the evaluation is performed in its context. The binding may > be a +Binding+ object or a +Proc+ object. If the optional > _filename_ and _lineno_ parameters are present, they will be used > when reporting syntax errors. > > def getBinding(str) > return binding > end > str = "hello" > eval "str + ' Fred'" #=> "hello Fred" > 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 > > joy0 == > [ [ [ joy0 body joy0 ] > [ [] ] > [ pop pop pop ] > [ cons pop cons ] > [ opcase pop opcase ] > [ body pop body ] > [ i pop joy0 ] > [ step pop [joy0] cons step ] > [ [] cons i ] ] > opcase > i ] > 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 > >