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]

The gh_enter question



I've noticed upon catching up on my e-mail that a new release of Guile
is planned for somewhere in the near future. I hope the annoying API
change of gh_enter can be resolved sometime before then. I've brought
this up before, but the gist of it is that gh_enter no longer loads
boot-9.scm, and while it is true that some programs may need this
behavior, it is also true that the old gh_enter behavior was useful
for other programs; not all programs that need boot-9.scm use gh_repl.
I earlier outline two possible solutions:

1) Add a gh_enter_with_boot_9 which has the old behavior; leave the
gh_enter changed as it has been.

2) Restore gh_enter to the way it was and add a gh_enter_sans_boot_9
which has the new behavior. I think this is preferrable. If you're
going to have two functions, one jsut like an old one and another
that's different, it makes more sense, generally to apply the old name
to the function with the old behavior. Also, I see no usefulness to
breaking old 1.2-based programs gratuitously.

I include patches for each version, so it only remains for someone to
pick which is the right solution and apply the patch. (Don't just run
this email through patch, since it contains two incompatible
patches). As I said, I prefer version 2, but either is much
preferrable to the way things are now (I have to implement my own
version of gh_enter in all my code because there's no easy way to tell
the difference between the old and new behaviors through autoconf).

 - Maciej Stachowiak


--------Version 1-------

ChangeLog comment:

* gh_init.c, gh.h: Add gh_enter_with_boot_9, which has the old
gh_enter behavior of loading boot-9.scm before calling the main
program.


diff -ru libguile/gh.h ../guile-mod/libguile/gh.h
--- libguile/gh.h	Sun Mar  1 02:25:59 1998
+++ ../guile-mod/libguile/gh.h	Tue Jun  2 16:54:46 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);
diff -ru libguile/gh_init.c ../guile-mod/libguile/gh_init.c
--- libguile/gh_init.c	Tue Nov 25 12:20:21 1997
+++ ../guile-mod/libguile/gh_init.c	Tue Jun  2 16:52:57 1998
@@ -72,6 +72,30 @@
   /* 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\")"); 
+  scm_ice_9_already_loaded = 1;
+  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 


--------Version 2-------

ChangeLog comment:

* gh_init.c, gh.h: Make gh_launch_pad load boot-9.scm again, reverting
Mark Gallasi's change of 1997-11-24; add gh_enter_sans_boot_9 which
has the current gh_enter behavior of not loading boot-9.scm.


diff -ru libguile/gh.h ../guile-mod/libguile/gh.h
--- libguile/gh.h	Sun Mar  1 02:25:59 1998
+++ ../guile-mod/libguile/gh.h	Tue Jun  2 16:58:53 1998
@@ -61,6 +61,7 @@
 #endif /* __GNUC__ */
 
 void gh_enter(int argc, char *argv[], void (*c_main_prog)());
+void gh_enter_sans_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);
diff -ru libguile/gh_init.c ../guile-mod/libguile/gh_init.c
--- libguile/gh_init.c	Tue Nov 25 12:20:21 1997
+++ ../guile-mod/libguile/gh_init.c	Tue Jun  2 17:00:31 1998
@@ -53,11 +53,35 @@
    called by scm_boot_guile, it can safely work with heap objects, or
    call functions that do so.  */
 static void 
-gh_launch_pad (void *closure, int argc, char **argv)
+gh_launch_pad_sans_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_sans_boot_9 (int argc, char *argv[], main_prog_t c_main_prog)
+{
+  scm_boot_guile (argc, argv, gh_launch_pad_sans_boot_9, (void *) c_main_prog);
+  /* 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 (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\")"); 
+  scm_ice_9_already_loaded = 1;
   c_main_prog (argc, argv);
   exit (0);
 }