On Wednesday 30 November 2005 11:00 am, Rob Browning wrote:
> If so, then I wondered if it might be possible to just implement the
> function mentioned originally
> i.e. ag_scm_c_eval_string_from_file_line, and here's what I came up
> with.  Note that I have no idea if this will actually work; I haven't
> tested it, and I don't know the semantics of the port related
> filename, line, and column bits offhand.
> 
>   (define (eval-port port)
>     ;; See strports.c inner_eval_string for similar code.
>     (let loop ((next-form (read port))
>                (any-read? #f)
>                (result #f))
>       (if (eof-object? next-form)
>           (if any-read? result)
>           (loop (read port)
>                 #t
>                 (primitive-eval next-form)))))
> 
>   (define (eval-string-from-file str filename line column)
>     (call-with-input-string str
>         (lambda (port)
>           (set-port-filename! port filename)
>           (set-port-line! port line)
>           (set-port-column! port column)
>           (eval-port port))))

With the final piece being the C code:

   SCM proc = scm_c_eval_string ("eval-string-from-file");
   SCM str  = scm_from_locale_string (scheme_text);
   SCM file = scm_from_locale_string (file_name);
   SCM line = scm_from_int (line_no);
   SCM res  = scm_call_3 (proc, str, file, line);
   //  Let's forget columns -- we don't have scm_call_4.

Actually, I might as well create the port in C and invoke "eval-port" directly.
I could easily set the column number, too.  (If I were tracking it.)

I'll give this a spin and let you know if it works shortly
(a day or two).  Thank you.  (I still think adding it to libguile
would not hurt.)

Regards, Bruce


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

Reply via email to