This is the mail archive of the guile@sourceware.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: building lists with gh_load()



AL> At the moment I have something like:
AL> SCM
AL> load_from_files_by_list(SCM list) {

AL> 	if (list == SCM_EOL)
AL> 		return SCM_EOL;
AL> 	else
AL> 		return gh_cons(gh_load(SCM_UCHARS(gh_car(list))),
AL> 						load_from_files_by_list(gh_cdr(list));
AL> }

A first comment: This really looks like something you'd rather do in
Scheme than in C. Unless you have removed stuff that makes the whole
thing C-worthy.

AL> But, unfortunately gh_load _always_ returns SCM_UNSPECIFIED.

Yup, that is because gh_load is supposed to be the C version of the
scheme procedure load which according to R5RS should return an
unspecified value. 

I was about to suggest you use gh_eval_file instead, but discovered
that gh_load is simply a macro that calls gh_eval_file. This is a bug, 
because guile-ref.info claims that gh_eval_file returns the value of
the last evaluated expression.

A work-around could be to read the files into strings, because I do
believe gh_eval_string works just right. Another solution could be to
use side-effects in the files you are loading. If the all set! a value 
X, then you recursive function could simply cons together the value of 
X with the list. 

	Best regards,
	Lars

-- 
Lars Arvestad               Dept. of Numerical Analysis and Computing Science
                       Royal Institute of Technology (KTH), Stockholm, Sweden

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