This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Not loading boot-9.scm



Mark Galassi <rosalia@cygnus.com> wrote:
> Maciej, do you think that it's OK to explicitly invoke
>
>   gh_eval_str ("(primitive-load-path \"ice-9/boot-9.scm\")");
>
> from your programs if you want to use ice-9 without gh_repl()?

I think it's OK as long as I have an easy way of knowing from
configure.in wether I need to, so I can support both 1.2 and the
recent snapshots. However, since I think this is a relatively common
need (boot-9 has a lot of fairly important features in it - the module
system, load, various R4RS functions, etc), I think it would be nice
to have a wrapper function to do it. Additionally, the existence of a
wrapper function makes it trivial to test with autoconf wether it
needs to be invoked or not.

> I prefer the former, since I think it would be good to have gh_enter()
> not load boot-9.scm, so that the library users have fine-grained
> control over the loading of Scheme code.

Well, it's mostly just a naming issue, but I think that if we end up
splitting a function into two with different names, the one with the
same semantics as the older version has a slightly better claim to the
old name.

In any case, here's a patch that adds gh_enter_with_boot_9 that has
the older semantics and leaves gh_enter alone. If you reconsider the
naming issue, the rename should be trivial to do.


--- gh_init.c   Tue Nov 25 12:20:21 1997
+++ gh_init.c.2 Fri Feb 20 14:08:50 1998
@@ -72,6 +72,29 @@
   /* never returns */
 }
 
+/* This function takes care of all real GH initialization.  Since it's
+   called by scm_boot_guile, it can safely work with heap objects, or
+   call functions that do so.  */
+static void 
+gh_launch_pad_with_boot_9 (void *closure, int argc, char **argv)
+{
+  main_prog_t c_main_prog = (main_prog_t) closure;
+
+  gh_eval_str ("(primitive-load-path \"ice-9/boot-9.scm\")"); 
+  c_main_prog (argc, argv);
+  exit (0);
+}
+
+/* starts up the Scheme interpreter, and stays in it.  c_main_prog()
+   is the address of the user's main program, since gh_enter() never
+   returns. */
+void 
+gh_enter_with_boot_9 (int argc, char *argv[], main_prog_t c_main_prog)
+{
+  scm_boot_guile (argc, argv, gh_launch_pad_with_boot_9, (void *) c_main_prog);
+  /* never returns */
+}
+
 /* offer a REPL to the C programmer; for now I just invoke the ice-9
    REPL that is written in Scheme */
 void 
--- gh.h        Tue Jan 20 12:57:00 1998
+++ gh.h.2      Fri Feb 20 14:10:43 1998
@@ -61,6 +61,7 @@
 #endif /* __GNUC__ */
 
 void gh_enter(int argc, char *argv[], void (*c_main_prog)());
+void gh_enter_with_boot_9(int argc, char *argv[], void (*c_main_prog)());
 void gh_repl(int argc, char *argv[]);
 SCM gh_catch(SCM tag, scm_catch_body_t body, void *body_data,
             scm_catch_handler_t handler, void *handler_data);