On Sun, 16 Sep 2001, Johann Hibschman wrote:
> Is there a good primer anywhere for embedding Ruby?  The only document
> I've found is README.EXT, which is more targetted to extensions than
> embeddings.

No primer, sorry.  I recommend looking at other embedded projects to get
going.  I'd suggest my own, ns_ruby, but it is sad and far from complete
as of yet.  I agree that a primer is highly in order.

> Ideally, I would like to start my program, define some new Ruby
> classes and methods to wrap my application logic, then start executing
> bits of code at the top level.

Skeleton code looks like:
main {
program_init();
ruby_init();
ruby_options(argc,argv);
Init_some_ruby_class();
maybe_instantiate_a_bunch_of_things_inside_ruby();
while(ruby_script_data = get_some_code(blah,blah)) {
   rb_eval_string_protect(ruby_script_data,NULL);
   handle_ruby_exceptions();
   do_other_things_after_ruby_is_done;
   }
}

> However, I can't find an obvious way to respond to Ruby exceptions,
> control threads, or to insulate myself from potential loops in the
> executed code.

'insulate myself from potential loops'?  Do you mean the halting problem?

As for the rest, there is a wealth of API to handle top-level Ruby
exceptions and such.  If you're more specific I can try to help.

> Is there a way to tell Ruby to, say, "execute 10 steps of code and
> return the continuation to me".

What's a step?  A block, a line, what?