Just for clarity does this mean Gambit's eval and compiler not only takes a sexp input (with or without location info annotations, depending on specific route), but also takes some kind of source code special object tree format?<br>

<br><div class="gmail_quote">2013/5/31 Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca" target="_blank">feeley@iro.umontreal.ca</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5"><br>
On May 31, 2013, at 9:40 AM, Marc Feeley <<a href="mailto:feeley@IRO.UMontreal.CA">feeley@IRO.UMontreal.CA</a>> wrote:<br>
<br>
><br>
> On May 31, 2013, at 9:28 AM, Nathan Sorenson <<a href="mailto:takeoutweight@hotmail.com">takeoutweight@hotmail.com</a>> wrote:<br>
><br>
>> When translating Clojure code to Scheme, I'm finding it quite easy to preserve source code information for the Gambit interpreter, so that when I get exceptions I am notified of the offending Clojure source lines. Is there an obvious way I could do this for compiled code as well?<br>


><br>
> There isn't a form for this, but that would be useful and I have thought about adding it.  Something like a "source-at" special form.<br>
><br>
> For example,<br>
><br>
>    (source-at "foo.scm" 10 2 ;; file line column<br>
>               ((source-at "foo.scm" 10 8 cons)<br>
>                (source-at "foo.scm" 10 8 x)<br>
>                (source-at "foo.scm" 10 10 y)))<br>
><br>
> would be equivalent to<br>
><br>
>    (cons x y)<br>
><br>
> but with explicit source location information.<br>
><br>
> Actually this source-at form can be easily defined as a macro give me a few minutes.<br>
<br>
</div></div>Here's the implementation of source-at.<br>
<br>
Marc<br>
<br>
;;; File: source-at.scm<br>
<br>
(##define-syntax source-at<br>
  (lambda (form)<br>
<br>
    (define (unwrap x)<br>
      (if (##source? x) (##source-code x) x))<br>
<br>
    (apply (lambda (_ path line col expr)<br>
             (##make-source<br>
              (unwrap expr)<br>
              (##make-locat<br>
               (##path->container (unwrap path))<br>
               (##make-filepos (- (unwrap line) 1) (- (unwrap col) 1) 0))))<br>
           (unwrap form))))<br>
<br>
;; test it:<br>
<br>
(define (f x y)<br>
  (+ 1<br>
<div class="im">     (source-at "foo.scm" 10 2 ;; file line column<br>
</div>                (/ x y))))<br>
<br>
(pp (f 100 0))<br>
<br>
;; Output:<br>
;;<br>
;; % gsi source-at.scm<br>
;; *** ERROR IN f, "foo.scm"@10.2 -- Divide by zero<br>
;; (/ 100 0)<br>
<br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</blockquote></div><br>