guile-devel
[Top][All Lists]
Advanced

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

Re: reprise: scm_c_eval_string_from_file_line


From: Andy Wingo
Subject: Re: reprise: scm_c_eval_string_from_file_line
Date: Tue, 08 Mar 2011 23:28:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi Bruce,

On Thu 24 Feb 2011 23:58, Bruce Korb <address@hidden> writes:

> Anyway, picking up threads from 2003 and 2008:
> http://osdir.com/ml/lisp.guile.devel/2003-05/msg00202.html
> http://www.mail-archive.com/address@hidden/msg02825.html
> http://www.mail-archive.com/address@hidden/msg02826.html
>
> I would really, _really_ appreciate being able to yank it out of
> my code.  Below is an example of what I go through to do it.
> It is simplified somewhat since I no longer support Guile 1.4.
>
> It simply doesn't feel like a straight forward interface.
> It feels like I am starting a "process this string" function,
> then inject some information, then call a function to scan
> a bit then process a bit.  How would it ever get compiled?
> It'd be nice to be able to say, "here's some text, from this
> file and this line number, give me back the compiled form"
> and then call the "run it" function.  But I can't.  I have to
> insert the file and line information.  It's icky code.

> SCM
> ag_scm_c_eval_string_from_file_line(
>     char const * pzExpr, char const * pzFile, int line)

So!  I implemented something, but it's not quite what you asked for.

You can change your implementation to this:

  {
    static SCM eval_string_var = SCM_BOOL_F;

    if (scm_is_false (eval_string_var))
      eval_string_var = scm_c_public_lookup ("ice-9 eval-string",
                                             "eval-string");

    return scm_call_5 (scm_variable_ref (eval_string_var),
                       string,
                       scm_from_locale_keyword ("file"),
                       pzFile ? scm_from_locale_string (pzFile) : SCM_BOOL_F,
                       scm_from_locale_keyword ("line"),
                       scm_from_int (line));
  }

If you want to compile the expression, add #:compile? #t to the keyword
arguments.  If you want to use a different language, use #:lang.  See
the manual in git for more.

Regards,

Andy
-- 
http://wingolog.org/



reply via email to

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