I had something of a problem with Guile, because when it arrayifies a list SCM it stringifies all elements of the list to convert them to SVs; this caused me horrible problems since one of the elements of my list was a continuation. Plus, it tried to convert the continuation to a double because the last compare in stringify was wrong (scm_ functions return an SCM, not an int return, plus it was testing for exact when it meant inexact). I've fixed the compare (I think) and I've tweaked the code so that it converts the list elements to Guile::SCM objects instead (since they can stringify later if needed anyway). There may be a better way to do this, but the following patch is what I'm using with some success -
*** guile_wrap.c.orig Thu Jan 1 22:05:34 2004 --- guile_wrap.c Thu Jan 1 22:05:36 2004 *************** *** 170,177 **** // might make sense if Perl had car and cdr! if (gh_list_p(scm)) { AV *av = newAV(); do { ! av_push(av, newSVscm(SCM_CAR(scm))); scm = SCM_CDR(scm); } while(scm != SCM_EOL); return newRV_noinc((SV*)av); --- 170,183 ---- // might make sense if Perl had car and cdr! if (gh_list_p(scm)) { AV *av = newAV(); + SV* sv; + SCM tmp; do { ! sv = newSV(0); ! tmp = SCM_CAR(scm); ! scm_gc_protect_object(tmp); ! sv_setref_pv(sv, "Guile::SCM", (void*)tmp); ! av_push(av, sv); scm = SCM_CDR(scm); } while(scm != SCM_EOL); return newRV_noinc((SV*)av); *************** *** 181,189 **** if (SCM_CONSP(scm)) { // create a two-element array with the CAR and CDR of the pair AV *av = newAV(); av_extend(av, 1); ! av_store(av, 0, newSVscm(SCM_CAR(scm))); ! av_store(av, 1, newSVscm(SCM_CDR(scm))); return newRV_noinc((SV*)av); } --- 187,205 ---- if (SCM_CONSP(scm)) { // create a two-element array with the CAR and CDR of the pair AV *av = newAV(); + SV* sv; + SCM tmp; av_extend(av, 1); ! sv = newSV(0); ! tmp = SCM_CAR(scm); ! scm_gc_protect_object(tmp); ! sv_setref_pv(sv, "Guile::SCM", (void*)tmp); ! av_store(av, 0, sv); ! sv = newSV(0); ! tmp = SCM_CDR(scm); ! scm_gc_protect_object(tmp); ! sv_setref_pv(sv, "Guile::SCM", (void*)tmp); ! av_store(av, 1, sv); return newRV_noinc((SV*)av); } *************** *** 192,198 **** return newSVpvn(SCM_STRING_CHARS(scm),SCM_STRING_LENGTH(scm)); // floats ! if (scm_exact_p(scm)) return newSVnv(gh_scm2double(scm)); croak("Guile::newSVscm : Unknown non-immediate SCM type."); --- 208,214 ---- return newSVpvn(SCM_STRING_CHARS(scm),SCM_STRING_LENGTH(scm)); // floats ! if (scm_inexact_p(scm) == SCM_BOOL_T) return newSVnv(gh_scm2double(scm)); croak("Guile::newSVscm : Unknown non-immediate SCM type."); ======== END OF PATCH ========== The reason I ran in to this is because I'm trying to get Guile working as a control language for POE programs by using a function that throws an exception with a continuation as one of the parameters, so the Guile execution pauses but returns the continuation. I then interpret the other arguments of the continuation as the details of a POE event to post, and when the results of the event's processing are posted back to the Guile POE::Session it re-invokes the continuation with them - so that the POE work is basically transparent from within the Guile code. I've got a working REPL using POE::Wheel::ReadLine (and a wrapper object which is started at the request of the initial Guile thread) and am going to add some more wrappers so you can actually do something with it. I'll lob a post out here when I've got code that does stuff; meantime, if you want a look at what I've got so far feel free to annoy me by e-mail :) -- Bring me my etherkiller; Oh clouds unfold! / Bring me the magic smoke of desire I shall not cease from mental fight / Nor shall my LART rest in my hand Till we have buried the bodies / Of all the lusers in all this land -- rpg, ASR [ My homepage is http://www.trout.me.uk/ ]