unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Bruce Korb <bruce.korb@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: Getting source location information
Date: Wed, 30 Nov 2005 12:53:50 -0800	[thread overview]
Message-ID: <200511301253.50840.bruce.korb@gmail.com> (raw)
In-Reply-To: <87hd9uezaa.fsf@trouble.defaultvalue.org>

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	other threads:[~2005-11-30 20:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-28  4:25 I don't want to maintain this Bruce Korb
2005-11-29  8:16 ` Ludovic Courtès
2005-11-29 20:14   ` Bruce Korb
2005-11-30  8:39     ` Ludovic Courtès
2005-11-30 12:30       ` Bruce Korb
2005-11-30 13:46         ` Ludovic Courtès
2005-11-30 14:00           ` Bruce Korb
2005-11-30 14:44             ` Getting source location information Ludovic Courtès
2005-11-30 15:30               ` Bruce Korb
2005-11-30 16:04                 ` Ludovic Courtès
2005-11-30 16:58                   ` Bruce Korb
2005-11-30 17:39                     ` Ludovic Courtès
2005-12-01 12:19                       ` Ludovic Courtès
2005-11-30 19:00                   ` Rob Browning
2005-11-30 20:53                     ` Bruce Korb [this message]
2005-11-30 22:35                       ` Rob Browning
2005-11-30 23:30                         ` Bruce Korb
2005-12-14 21:54                           ` Kevin Ryde
2005-11-30 23:45                 ` Han-Wen Nienhuys
2005-12-01  0:30 ` I don't want to maintain this Kevin Ryde
2005-12-01  0:38 ` Kevin Ryde
2005-12-07  0:36   ` Marius Vollmer

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=200511301253.50840.bruce.korb@gmail.com \
    --to=bruce.korb@gmail.com \
    --cc=guile-devel@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).