From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.devel Subject: Re: Getting source location information Date: Wed, 30 Nov 2005 11:00:45 -0800 Message-ID: <87hd9uezaa.fsf@trouble.defaultvalue.org> References: <200511272025.32395.bruce.korb@gmail.com> <200511300600.54799.bruce.korb@gmail.com> <878xv62o13.fsf_-_@laas.fr> <200511300730.44076.bruce.korb@gmail.com> <87psoixgtv.fsf@laas.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1133378401 30992 80.91.229.2 (30 Nov 2005 19:20:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 30 Nov 2005 19:20:01 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Nov 30 20:19:50 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EhXCK-0004MT-34 for guile-devel@m.gmane.org; Wed, 30 Nov 2005 20:00:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EhXCJ-0005Vm-8P for guile-devel@m.gmane.org; Wed, 30 Nov 2005 14:00:55 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EhXCF-0005VX-9G for guile-devel@gnu.org; Wed, 30 Nov 2005 14:00:51 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EhXCD-0005VL-Ok for guile-devel@gnu.org; Wed, 30 Nov 2005 14:00:51 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EhXCD-0005VI-LO for guile-devel@gnu.org; Wed, 30 Nov 2005 14:00:49 -0500 Original-Received: from [70.85.129.156] (helo=defaultvalue.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EhXCD-0007CL-86 for guile-devel@gnu.org; Wed, 30 Nov 2005 14:00:49 -0500 Original-Received: from omen.defaultvalue.org (localhost [127.0.0.1]) by defaultvalue.org (Postfix) with ESMTP id 5C80890D2B; Wed, 30 Nov 2005 13:00:55 -0600 (CST) Original-Received: from trouble.defaultvalue.org (omen.defaultvalue.org [192.168.1.1]) by omen.defaultvalue.org (Postfix) with ESMTP id 52848400E; Wed, 30 Nov 2005 11:00:47 -0800 (PST) Original-Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id 1880C41180; Wed, 30 Nov 2005 11:00:45 -0800 (PST) Original-To: Bruce Korb In-Reply-To: <87psoixgtv.fsf@laas.fr> (Ludovic =?iso-8859-1?Q?Court=E8s's?= message of "Wed, 30 Nov 2005 17:04:28 +0100") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:5436 Archived-At: ludovic.courtes@laas.fr (Ludovic Court=E8s) writes: > If you want to use source locations in a Guile-friendly way (so that > Guile can, for instance, display location information in > backtraces), then you may want to use `scm_set_source_property_x > (sexp, key, datum)' (where KEY may be one of SCM_SYM_FILENAME, > SCM_SYM_LINE, SCM_SYM_COLUMN) which is defined in `srcprop.h'. I think this is probably more along the lines of what he wants, but is the above going to work correctly if there are multiple lines of Scheme code? For example: [This is an example ] (do-something (foo) (bar)) (let ((baz bax)) (do-something-else baz) (more-stuff baz) (and-even-more baz)) [ ...with several lines of embedded Scheme code. ] If I'm guesssing correctly about how scm_set_source_property_x works (I haven't used it), then it seems like it might be a lot of work to turn the above lines of Scheme code into a properly filename, line (and column?) annotated set of forms. 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)))) --=20 Rob Browning rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu GPG starting 2002-11-03 =3D 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 7= 3A4 _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel