[Top][All Lists]

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

Re: I don't want to maintain this

From: Ludovic Courtès
Subject: Re: I don't want to maintain this
Date: Wed, 30 Nov 2005 09:39:29 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

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?

The point is that writing Scheme code will always be easier than writing
C code, and maintaining it will be even more easier.

> And I do not understand the usage of the "file"
> argument.  What I am doing is extracting Scheme code from an encompassing
> template and handing it off for evaluation.  My program is reading the
> file, not Guile.  When I hand off the the string for evaluation, I hand
> it to that ugly thing that I do not want to maintain.  I do this in
> exactly the same way as one would with scm_c_eval_string, except I have
> the additional parameters file name and line number.  Perhaps I could
> wrap my strings in something like this:
> 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?

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"));

Hope this helps,

reply via email to

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