I agree that this would be helpful.

On Nov 2, 6:34 pm, Mark McGranaghan <[EMAIL PROTECTED]> wrote:
> I really like being able to find and check documentation in the REPL
> with find-doc and doc, but I often would like to see the source code
> of a function or macro to be able to understand it better or learn
> from the implementation. To do this I switch into an editor with
> boot.clj, find and read the source, then switch back into the REPL.
> Doing this a lot got me thinking, what if we could just do e.g.
>
> user=> (source filter)
> (defn filter
>   "Returns a lazy seq of the items in coll for which
>   (pred item) returns true. pred must be free of side-effects."
>   [pred coll]
>     (when (seq coll)
>       (if (pred (first coll))
>         (lazy-cons (first coll) (filter pred (rest coll)))
>         (recur pred (rest coll)))))
> nil
> user=>
>
> This might also be also be useful for programatically generating
> documentation with handy "view source" links.
>
> I was think for the source macro something like:
> (defmacro source
>   "Prints the source text of the top-level form in which var was
> created."
>   [name]
>   `(if-let src-txt# (:source (meta (var ~name)))
>      (println src-txt#)
>      (println "no source found"))))
>
> For that to work we would need a :source meta value like we currently
> have for :line and :file.
>
> My questions then are:
> - Does the general idea of a source macro or something similar sound
> useful? Am I missing something that renders such a feature
> unnecessary?
> - How might one implement the source macro and the associated support
> in the reader/compiler?
>
> Thanks for your thoughts,
> - Mark
--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to