cardinal-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Cardinal-dev] RubyInRuby parser/compiler


From: Erik Bågfors
Subject: Re: [Cardinal-dev] RubyInRuby parser/compiler
Date: 01 Jan 2003 23:07:17 +0100

On Wed, 2003-01-01 at 22:29, David Robins wrote:
> > during the holidays I played around with the ruby-parser that can be
> > found in the ruby cvs under lib/metaruby/ruby-parser.
> >
> > My experiences so far has been great!  I really think we can use this
> > baby to write the parrot compiler.  If we only had objects working in
> > parrot I think we could get very far in a short time.
> 
> I prefer ruth, but maybe I didn't look at that parser.  What's it written
> in?  Ruby or C?  Does it generate an AST?

check the subject of the mail :)
It's a ruby in ruby parser.

It generates an AST that I think it identical to the one used by Ruth. 
I'm uncertain about that but it looks very much like when I tried Ruth.

There are a number of reasons why I prefer a
ruby-in-ruby-parser/compiler:
* Ruth will be totally outdated once ruby 2.0 is here.  A
ruby-in-ruby-parser/compiler can be built on to make it 2.0 compatible.
* If we can compile the compiler into parrot bytecode it should be quite
easy to get eval and stuff like that to work.

> 
> I have written some code using Ruth that generates IMCC code, and I stopped
> precisely because I needed to clarify some issues with operators and needed
> OO support (see perl6-internals).

That's pretty much as far as I got too :)

> > One think I noticed when started to think about what it means that
> > EVERYTHING is an object is that everything has to be objects :)
> >
> > For example, the following ruby code
> > a=1+2
> >
> > Will have to be quite long.  What we have to do here is
> 
> > * Create a object of type "Fixnum"
> > * Set that object to the value 1
> > * Create another object of type "Fixnum"
> > * Set that object to the value 2
> > * lookup the subrutine "+" in the first object (or maybe it's enough to
> > look that up in the class "Fixnum")
> 
> Well, actually I don't think it's that bad, since if we invoke the Parrot
> "add" operation, then it can call the PMC's add function and provide various
> shortcuts, perhaps not having to do a method lookup if the lhs is, say, a
> RubyFixnum or a RubyInteger.  Only the RubyObject PMC need invoke a '+'
> method.

Well, can you change the pmc:s add operation?  Can you add new methods
to a PMC? In ruby it is possible to change the "+" method whenever you
want.  Of course we can choose to be alittle incompatible if we like.

[CUT]

/Erik

-- 
Erik Bågfors               | address@hidden
Supporter of free software | GSM +46 733 279 273
fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32



reply via email to

[Prev in Thread] Current Thread [Next in Thread]