* primitive inclusion @ 2003-07-25 20:08 Peter S. Christopher 2003-07-26 4:23 ` Steve Tell 0 siblings, 1 reply; 3+ messages in thread From: Peter S. Christopher @ 2003-07-25 20:08 UTC (permalink / raw) Hi listers, I'm having a problem finding a primitive function in one of my modules. Here is the setup. I have a C program which (after booting guile) defines a routine a-la: scm_c_define_gsubr("dvect?", 1, 0 ,0, dvect_p); Then the program loads a file using scm_c_primitive_load("root.scm"); At the top of root.scm I include a module via: (use-modules (slab)) Now within the text of the slab.scm I expect to use dcect?. However, the guile cannot reference dvect? -- it can't find it. The problem is that dvect? is being put in the (guile-user) module. And the slab module can't see it. I've tried to (use-modules (guile-user)) and this seems to have no effect. Does anyone have any ideas how I can get it so that the slab module can see dvect? ? Thanks for any help, Pete _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: primitive inclusion 2003-07-25 20:08 primitive inclusion Peter S. Christopher @ 2003-07-26 4:23 ` Steve Tell 2003-07-26 18:03 ` Peter S. Christopher 0 siblings, 1 reply; 3+ messages in thread From: Steve Tell @ 2003-07-26 4:23 UTC (permalink / raw) Cc: guile-user On Fri, 25 Jul 2003, Peter S. Christopher wrote: > Hi listers, > > I'm having a problem finding a primitive function in one of my > modules. Here is the setup. I have a C program which (after > booting guile) defines a routine a-la: > > scm_c_define_gsubr("dvect?", 1, 0 ,0, dvect_p); > > Then the program loads a file using > > scm_c_primitive_load("root.scm"); > > > At the top of root.scm I include a module via: (use-modules (slab)) Now > within the text of the slab.scm I expect to use dcect?. However, the guile > cannot reference dvect? -- it can't find it. The problem is that dvect? is > being put in the (guile-user) module. And the slab module can't see it. > I've tried to (use-modules (guile-user)) and this seems to have no effect. > > Does anyone have any ideas how I can get it so that the slab module can > see dvect? ? I had similar problems trying to make a program compatible with both guile-1.5/1.6 and guile-1.4 - one of the differences between the two is which module C primitives end up in vs. the default module that scheme code runs in. I came up with this hack, placed immediately after initializing guile and before defining primitives to make guile-1.6 behave enough like 1.4: #ifdef HAVE_SCM_C_READ_STRING { SCM exp = scm_c_read_string("(define-module (guile))"); scm_primitive_eval_x(exp); } #endif While this works, making guile 1.6 behave like 1.4 isn't really the way to go any longer. I see that the guile-1.6.4 reference manual has a nice section "Accessing Modules from C." (thanks authors!) When writing a program for guile >= 1.6 only, it appears that one should use scm_c_define_module() to place their C primitives into the desired application-specfic module. Steve > Thanks for any help, > > Pete > > _______________________________________________ > Guile-user mailing list > Guile-user@gnu.org > http://mail.gnu.org/mailman/listinfo/guile-user > -- -- Steve Tell tell@telltronics.org _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: primitive inclusion 2003-07-26 4:23 ` Steve Tell @ 2003-07-26 18:03 ` Peter S. Christopher 0 siblings, 0 replies; 3+ messages in thread From: Peter S. Christopher @ 2003-07-26 18:03 UTC (permalink / raw) Cc: guile-user Hi there, Thanks for the help Steve, worked like a charm. For the benefit of anyone who is interested: here is how one defines primitives in the (guile) module (rather than the (guile-user) module which seems to be standard). <CODE> SCM slab_write_sloppy(); SCM slab_read_sloppy(); SCM map_globals(); SCM dvect_p(); void init_my_proc(void *data){ scm_c_define_gsubr("slab-write-sloppy", 5, 0 ,0, slab_write_sloppy); scm_c_define_gsubr("slab-read-sloppy", 4, 0 ,0, slab_read_sloppy); scm_c_define_gsubr("map-globals", 1, 0 ,0, map_globals); scm_c_define_gsubr("dvect?", 1, 0 ,0, dvect_p); return; } static void inner_main (void *closure, int argc, char **argv){ /*VARIABLES AND WHAT NO*/ // This call makes the "guile" module the current-module for the // duration of the call to init_my_proc scm_c_define_module("guile", init_my_proc, NULL); /*Etcetera*/ } </CODE> Thanks again. Pete On Sat, 26 Jul 2003, Steve Tell wrote: > On Fri, 25 Jul 2003, Peter S. Christopher wrote: > > > Hi listers, > > > > I'm having a problem finding a primitive function in one of my > > modules. Here is the setup. I have a C program which (after > > booting guile) defines a routine a-la: > > > > scm_c_define_gsubr("dvect?", 1, 0 ,0, dvect_p); > > > > Then the program loads a file using > > > > scm_c_primitive_load("root.scm"); > > > > > > At the top of root.scm I include a module via: (use-modules (slab)) Now > > within the text of the slab.scm I expect to use dcect?. However, the guile > > cannot reference dvect? -- it can't find it. The problem is that dvect? is > > being put in the (guile-user) module. And the slab module can't see it. > > I've tried to (use-modules (guile-user)) and this seems to have no effect. > > > > Does anyone have any ideas how I can get it so that the slab module can > > see dvect? ? > > I had similar problems trying to make a program compatible with both > guile-1.5/1.6 and guile-1.4 - one of the differences between the two is > which module C primitives end up in vs. the default module that scheme > code runs in. > > I came up with this hack, placed immediately after initializing guile and > before defining primitives to make guile-1.6 behave enough like 1.4: > > #ifdef HAVE_SCM_C_READ_STRING > { SCM exp = scm_c_read_string("(define-module (guile))"); > scm_primitive_eval_x(exp); } > #endif > > While this works, making guile 1.6 behave like 1.4 isn't really the way to > go any longer. > > I see that the guile-1.6.4 reference manual has a nice section "Accessing > Modules from C." (thanks authors!) > > When writing a program for guile >= 1.6 only, it appears that one should > use scm_c_define_module() to place their C primitives into the desired > application-specfic module. > > Steve > > > > Thanks for any help, > > > > Pete > > > > _______________________________________________ > > Guile-user mailing list > > Guile-user@gnu.org > > http://mail.gnu.org/mailman/listinfo/guile-user > > > > -- > -- > Steve Tell tell@telltronics.org > > _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-07-26 18:03 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-07-25 20:08 primitive inclusion Peter S. Christopher 2003-07-26 4:23 ` Steve Tell 2003-07-26 18:03 ` Peter S. Christopher
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).