unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Bruce Korb <bkorb@gnu.org>
Cc: tès <ludo@gnu.org>, "guile-devel Development" <guile-devel@gnu.org>
Subject: Re: reprise: scm_c_eval_string_from_file_line
Date: Tue, 08 Mar 2011 23:28:01 +0100	[thread overview]
Message-ID: <m3wrk98cy6.fsf@unquote.localdomain> (raw)
In-Reply-To: <4D66E288.7030608@gnu.org> (Bruce Korb's message of "Thu, 24 Feb 2011 14:58:16 -0800")

Hi Bruce,

On Thu 24 Feb 2011 23:58, Bruce Korb <bkorb@gnu.org> 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/guile-devel@gnu.org/msg02825.html
> http://www.mail-archive.com/guile-devel@gnu.org/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/



  parent reply	other threads:[~2011-03-08 22:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4.1298297717.17321.info-gnu@gnu.org>
     [not found] ` <87vd0cqjvx.fsf@gnu.org>
     [not found]   ` <4D643043.6080406@gnu.org>
     [not found]     ` <4D658101.7030307@gnu.org>
     [not found]       ` <87sjvdl6ce.fsf@gnu.org>
2011-02-24 22:58         ` reprise: scm_c_eval_string_from_file_line Bruce Korb
2011-02-25 11:13           ` Andy Wingo
2011-03-08 22:28           ` Andy Wingo [this message]
2011-03-08 22:45             ` Bruce Korb
2011-03-08 22:52               ` Andy Wingo
2011-03-09  6:30                 ` Mark H Weaver
2011-03-09 10:07               ` Ludovic Courtès
2011-03-09 20:15                 ` Andy Wingo
2011-03-10  9:35                   ` Bruce Korb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3wrk98cy6.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=bkorb@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).