[slime-devel] Re: #line

Helmut Eller heller at common-lisp.net
Sun Jun 8 13:09:02 UTC 2008


* Nikodemus Siivola [2008-06-08 13:17+0200] writes:

> Sorry, I misunderstood. So you'd want something like
>
>  (grab-source-location loc
>    (something (with-grabbed-source-location loc (something-else))
>
> or
>
>  (grab-source-location *magic*)
>
>  (something)
>
>  (something (with-grabbed-source-location *magic* (something-else)))
>
>
> which would result SOMETHING-ELSE getting the same source location as
> it would without the surrounding and preceding forms?

Yes, that's the idea.

>
> Do you need both, or only the first one?

I don't have real need right now.  This is more a would-be-nice-to-have
thing.  I'd like to have something like:

 (declare (source-location "foo/bar.lisp" LINE COLUMN))
 (foo)
 (bar)

So that (FOO) and (BAR) are compiled with the adjusted source location.
Ideally this would also work inside LOCALLY.  But it would be nice if
the arguments could be something mundane like filenames and line-numbers
rather then SBCL style source-paths or form-numbers.  Those source-paths
are rather hard to generate for something like Emacs.

A way to get the source location to feed it back later would also be
nice.  I'm thinking about something like:

(defmacro foo (exp)
   `(progn 
      (declare (source-location ,(get-source-location (nth 10 exp))))
      (something-new)))

In this case (SOMETHING-NEW) would have the same source location as the
10th element of exp, even though the expressions don't share any
structure.  Useful would be if the hypothetical GET-SOURCE-LOCATION would
work on any expression returned by READ or an equivalent parsing
function.

The idea is to use this in a preprocessor which generates a lisp file.
The file is then compiled as usual with COMPILE-FILE.  Think of a
Dylan-to-Lisp translator.

Helmut.




More information about the slime-devel mailing list