Reading the ruby source

R

Robbie Carlton

------=_Part_29640_14200149.1127237129891
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi.
I'd like to read the ruby source (that is, the source that when compiled,=
=20
yields the ruby interpreter). I have them, and I've had a look, but I just=
=20
get overwhelmed. I've never read a big c program before, and I was wonderin=
g=20
if anyone had any advice on where to start, or if there has been any=20
documentation?
Sorry it's a bit OT
thanks

robbie

------=_Part_29640_14200149.1127237129891--
 
J

Jamis Buck

Hi.
I'd like to read the ruby source (that is, the source that when
compiled,
yields the ruby interpreter). I have them, and I've had a look, but
I just
get overwhelmed. I've never read a big c program before, and I was
wondering
if anyone had any advice on where to start, or if there has been any
documentation?
Sorry it's a bit OT
thanks

robbie

It depends on what you want to get out of reading the source. Do you
want to understand some particular aspect of Ruby? Or do you just
want to understand what it does, from the moment you invoke the
interpreter?

If you just want an overall understanding of the flow of the
interpreter, I'd recommend starting with main. Then, with grep at
your side, step through the function and the functions it calls.

- Jamis
 
W

why the lucky stiff

Robbie said:
Hi.
I'd like to read the ruby source (that is, the source that when compiled,
yields the ruby interpreter). I have them, and I've had a look, but I just
get overwhelmed. I've never read a big c program before, and I was wondering
if anyone had any advice on where to start, or if there has been any
documentation?
Try README.EXT which comes with Ruby. It'll give ya a quick gloss over
everything.

From there, I'd look over ruby.h and intern.h, which will give you a
tour of the major structs and functions.

When you start diving into the various source files, note the Init_
functions at the end of each of them. (string.c has an Init_String,
marshal.c has Init_marshal, etc.) These functions create the actual
Ruby modules, classes and methods from their C counterparts.

_why
 
R

Robbie Carlton

------=_Part_30373_4780456.1127253264776
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

thanks for the road-map. I've just got stuck in. README.EXT is very handy,=
=20
and I hadn't even thought of grep (I'm on a mac, and the unix underbelly is=
=20
still not second nature yet).
also, kudos for the funny book why.

=20
Robbie Carlton wrote:
=20
Try README.EXT which comes with Ruby. It'll give ya a quick gloss over
everything.
=20
From there, I'd look over ruby.h and intern.h, which will give you a
tour of the major structs and functions.
=20
When you start diving into the various source files, note the Init_
functions at the end of each of them. (string.c has an Init_String,
marshal.c has Init_marshal, etc.) These functions create the actual
Ruby modules, classes and methods from their C counterparts.
=20
_why
=20

------=_Part_30373_4780456.1127253264776--
 
N

Nicholas Van Weerdenburg

thanks for the road-map. I've just got stuck in. README.EXT is very handy= ,
and I hadn't even thought of grep (I'm on a mac, and the unix underbelly = is
still not second nature yet).
also, kudos for the funny book why.
=20

=20
=20

Also it might help to read about creating C extensions for ruby. The
pick-axe book has a chapter.

--=20
Nicholas Van Weerdenburg
 
R

Rob Rypka

------=_Part_43600_23404516.1127255654969
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I've never read a big c program before, and I was wondering
if anyone had any advice on where to start, or if there has been any
documentation?
=20

While reading any big C program, I recommend using setting up Cscope. Some=
=20
projects have this as a target in the Makefile (although I don't remember i=
f=20
Ruby is one of them). You can quickly search for functions when you run int=
o=20
them, without the grepping. If you prefer, you can even set up Emacs or Vim=
=20
with cscope. For more info:

http://cscope.sourceforge.net/

Rob

------=_Part_43600_23404516.1127255654969--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top