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 following is a patch file to fix a bug (shortcoming?) in gh_enter of Guile 1.3. The problem with Guile 1.3's gh_enter is that it doesn't load boot-9.scm until gh_repl is called, meaning that Scheme code loaded outside of a repl loop cannot use standard primitives such as defmacro and load. Guile 1.2's gh_enter did load boot-9.scm and did not have this problem. I have combined my patch with that of mstachow@mit.edu. The behavior of gh_enter is modified to load the boot code. The current Guile 1.3 behavior, not loading the boot code, is preserved in a new routine, gh_enter_sans_init. Essentially, the new code separates the loading of init files in gh_repl (actually, scm_compile_shell_switches) into its own function. This function is called from both the repl code and via gh_enter. It keeps track of how many times it is called, so it is only loaded once, even if gh_repl is called from within gh_enter. Cordially, Steven G. Johnson stevenj@alum.mit.edu ------------------------------------------------------------------------------ diff guile-core-19980603/libguile//gh.h guile-1.3a/libguile//gh.h 63a64 > void gh_enter_sans_init(int argc, char *argv[], void (*c_main_prog)()); diff guile-core-19980603/libguile//gh_init.c guile-1.3a/libguile//gh_init.c 60c60 < /* gh_eval_str ("(primitive-load-path \"ice-9/boot-9.scm\")"); */ --- > scm_load_init(); /* load the boot code, etcetera */ 73a74,90 > > /* Alternate versions of gh_enter and gh_launch_pad that don't load the > boot code: */ > > static void gh_launch_pad_sans_init (void *closure, int argc, char **argv) > { > main_prog_t c_main_prog = (main_prog_t) closure; > > c_main_prog (argc, argv); > exit (0); > } > > void gh_enter_sans_init (int argc, char *argv[], main_prog_t c_main_prog) > { > scm_boot_guile (argc, argv, gh_launch_pad_sans_init, (void *) c_main_prog); > } diff guile-core-19980603/libguile//script.c guile-1.3a/libguile//script.c 432a433,459 > /* Load initialization files (e.g. the ice-9 system). This is called > by scm_shell (or rather, by scm_compile_shell_switches), but you > need to call it separately if you want to use the Scheme functions > defined in this file when running non-interactively. For example, > it is called via gh_enter so that gh user code can use things > like load, defmacro, etcetera. */ > void scm_load_init(void) > { > static int already_called = 0; /* we only want to do this once */ > if (!already_called) { > /* We want a path only containing directories from GUILE_LOAD_PATH, > SCM_SITE_DIR and SCM_LIBRARY_DIR when searching for the site init > file, so we do this before loading Ice-9. */ > SCM init_path = scm_sys_search_load_path(scm_makfrom0str ("init.scm")); > > /* Load Ice-9. */ > if (!scm_ice_9_already_loaded) > scm_primitive_load_path (scm_makfrom0str ("ice-9/boot-9.scm")); > > /* Load the init.scm file. */ > if (SCM_NFALSEP (init_path)) > scm_primitive_load (init_path); > > already_called = 1; /* don't call next time */ > } > } > 623,627d649 < { < /* We want a path only containing directories from GUILE_LOAD_PATH, < SCM_SITE_DIR and SCM_LIBRARY_DIR when searching for the site init < file, so we do this before loading Ice-9. */ < SCM init_path = scm_sys_search_load_path (scm_makfrom0str ("init.scm")); 629,636c651 < /* Load Ice-9. */ < if (!scm_ice_9_already_loaded) < scm_primitive_load_path (scm_makfrom0str ("ice-9/boot-9.scm")); < < /* Load the init.scm file. */ < if (SCM_NFALSEP (init_path)) < scm_primitive_load (init_path); < } --- > scm_load_init(); diff guile-core-19980603/libguile//script.h guile-1.3a/libguile//script.h 56a57 > extern void scm_load_init(void);