[Top][All Lists]

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

Re: [PATCH] for strports.c: scm_c_eval_string_from_file_line

From: Marius Vollmer
Subject: Re: [PATCH] for strports.c: scm_c_eval_string_from_file_line
Date: 01 Jun 2003 22:00:31 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Bruce Korb <address@hidden> writes:

> 2003-05-24  Bruce Korb  <address@hidden>
>       * guile-core/libguile/strports.c(scm_c_eval_string_from_file_line):
>       new procedure.  Facilitate error messages for applications that
>       extract scheme code from their input files.

Hmm, I'm not sure whether we should provide such a function as a ready
made unit.  Evaluation from strings (maybe with embedded new lines,
maybe more than one string, etc) while maintaining the line number,
the current module, etc, might come in several variations, I think.

We should provide the building blocks so that people can easily
implement what they want cleanly so that
scm_c_eval_string_from_file_line is very easy to implement.

What you can do right now is, for example (and untested, sorry):

  scm_c_primitive_load_from_string (const char *str,
                                    const char *filename, int line)
    SCM port, exp;

    port = scm_open_input_string (scm_str2string (str));
    scm_set_port_file_name_x (port, scm_str2string (filename));
    scm_set_port_line_x (port, scm_int2num (line));

    while (!SCM_EOF_OBJECT_P (exp = scm_read (port)))
      scm_primitive_eval_x (exp);

I think this quite straightforward, no?  But we might want to offer it
ready-made, anyway.  Opinions?

GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405

reply via email to

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