Suppose that 'future-fact' is a macro. Its declaration is this:

(defmacro future-fact [& forms] ...

Here's a use of the macro:

(future-fact "some text" (+ 1 2))

The metadata on the (+ 1 2) form will contain the line number. However, 
consider this:

(future-fact "some text")

Strings don't get line numbers attached to them, so there's no way for the 
future-fact code to find a line number to report. (Let's assume that, in this 
context, you can't make a throwable and look in its stack.)

However: the macroexpansion comes after a list is read. That list (I bet) 
*does* have a line number on it. So if the definition of future-fact could 
somehow be this:

(defmacro future-fact [& forms]
   (let [lineno (:line (meta ...some-way-to-get-the-original-call-form...))] 
...))

... I could get a good line number. Is there any way to get the original call 
form? Something like &env? Some hook into the reader?

-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Author of /Ring/ (forthcoming; sample: http://bit.ly/hfdf9T)
www.exampler.com, www.exampler.com/blog, www.twitter.com/marick

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to