It might be possible to get other info (such as var-name, var-body
etc), but it's mostly subjective (depending on the form being passed):

https://bitbucket.org/kumarshantanu/clj-miscutil/src/e16432dc0b6c/src/main/clj/org/bituf/clj_miscutil.clj#cl-251

Regards,
Shantanu

On Dec 9, 3:04 pm, Ken Wesson <kwess...@gmail.com> wrote:
> On Thu, Dec 9, 2010 at 4:48 AM, Sunil S Nandihalli
>
> <sunil.nandiha...@gmail.com> wrote:
> > hmm.. so how do we get the file name inside our macro??
>
> I guess we ask nicely for it to be added to the &form metadata in 1.3. :)
>
> Interestingly, extracting the correct line number in cases of
> multi-line forms is already handled:
>
> (ns faddle)
> (defmacro foo [x] `(quote ~(meta (second &form))))
> (defn futz [] (foo
>                 (bar baz)))
> faddle=> (futz)
> {:line 4}
>
> Not 3 or nil, 4. The subform (bar baz) has its own metadata with the
> correct line number. Since new, non-blank lines almost always start
> with an open parenthesis after the leading whitespace, pretty much any
> error can be localized to the correct line number even if the macro
> body spans multiple lines. Furthermore, the exception lines tend to
> contain a literal followed by a close paren, as with the final line in
>
> (if foo
>   (bar quux baz)
>   42)
>
> and there's *usually* nothing that can go wrong on such a line. When
> there is it's usually an error in a *form* inside the literal:
>
> (if foo
>   (bar quux baz)
>   [42 (count mumble) (.lastIndexOf frotz \q) 3 (19)])
> ;oops! -----------------------------------------^^
>
> and that form will again have line metadata.

-- 
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