guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I don't want to maintain this


From: Bruce Korb
Subject: Re: I don't want to maintain this
Date: Wed, 30 Nov 2005 04:30:08 -0800
User-agent: KMail/1.7.1

On Wednesday 30 November 2005 12:39 am, Ludovic Courtès wrote:
> Hi Bruce,
> 
> Bruce Korb <address@hidden> writes:
> 
> > *I* certainly cannot.
> 
> Do you mean that you don't *want* to, or that this is not possible?

Well, okay, I don't find the stuff obvious.  With effort, I'm sure
I could puzzle it out.  I have never found Lisp to be inherently
"obvious".

> > char* fmt =
> > "(read-enable 'positions)
> > (format #t \"evaluating `~a' from ~a:~a:~a~%%\"
> >             sexp (port-filename (current-input-port))
> >            (source-property sexp \"%s\")
> >            (source-property sexp %d))
> > (begin
> >    %s
> > )";
> >
> > and use it thus:
> >
> >    sprintf( buf, fmt, filename, linenum, script );
> >    result = scm_c_eval_string( buf );
> >
> > Would that work?
> 
> That might work, but that's "ugly".  Are you evaluating reading a file
> and evaluating it from C code?

I extract the scheme code from a file.  Now, I have a string in memory
and I want it eval-ed.  If I was reading your suggestion correctly,
I would need to write that string to a real file.  I want to avoid
that.  I want to hand that string, from memory, to Guile and tell
Guile, "This string came from file XXX on line NNN."  (That is what
the ag_scm_c_eval_string_from_file_line() does.)

> Even if this is the case, nothing prevents you from writing your own
> read/eval function in Scheme (along the lines of what I posted earlier)
> and using it from C:
> 
>   eval_proc = scm_c_eval_string ("eval-from-file");
>   result = scm_call_1 (eval_proc, scm_from_locale_string ("the-file.scm"));

Or this?

   SCM body = scm_from_locale_string (extracted_text);
   SCM file = scm_from_locale_string (current_input_file);
   SCM line = scm_from_<integer?> (line_num);
   return scm_call_3 (eval_proc, body, file, line);

Obviously, ``eval-from-file'' has to be reformulated to eval "body" instead of
reading input from a file and it must set the file name and line number
from the passed in arguments, but something like this ought to be workable,
yes?  Sorry for being dense, but just how to formulate the "eval-from-xxx" thing
isn't real obvious to me.  Thank you for your help & patience.  Regards, Bruce




reply via email to

[Prev in Thread] Current Thread [Next in Thread]