On Sat, Dec 07, 2002 at 06:03:46AM +0900, Paul Brannan wrote:
> On Sat, Dec 07, 2002 at 04:54:08AM +0900, Rich Kilmer wrote:
> > Matz does not hold the source code in memory so...no you cannot (unless
> > you did your own loading of the proc from eval'ing a string and then
> > keeping a handle to it.)
> 
> Matz does keep nodes for line numbers, though.  So one (very ugly)
> possibility would be to:
> 
>   - Find the first node for the proc
>   - Find the first NODE_NEWLINE; that should contain the line number the
>     proc starts on.
>   - Open the file that node points to and start reading.
> 
> This will let you get a string from a proc, but procs contain a lot more
> state than just the nodes that need to be evaluated.  Saving this state
> and reloading it would be an interesting exercise, to say the least.

Indeed, for it would allow/need/overlap the following projects:
 * RubyInRuby parsers and AST dumpers, if the code is saved as an AST
 * Rite: if bytecode is used
 * distributing ruby apps as a single executable
 * image-based Ruby (la Smalltalk): all the context could be dumped by
  a "top level proc"
 * distributed Ruby: yet another way to do it

everything from the top of my head, but there's for sure many more...

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Turn right here. No! NO! The OTHER right!