Why not generalize further then? Have a macro def-foo-let (actual name)
that takes a name and an operator (function or macro), so that

(defn print-out [x]
  (println x)
  x)

(def-foo-let print-let print-out)

will generate a print-let that prints each thing as it's computed, and

(def-foo-let time-let time)

will generate a time-let that times each thing, with expansions behaving as:

(let [a (second (print-out ['a (expr-computing-a)]))]
  body)

and

(let [b (second (time ['b (expr-computing-b)]))]
  body)

and the first one printing out things like

[pi 3.1415926535]

by way of illustration.



On Thu, Mar 28, 2013 at 1:14 PM, Jim - FooBar(); <jimpil1...@gmail.com>wrote:

>  Nice, thanks... :)
> I've started writing a very similar namespace but instead of printing, I'm
> timing...would you be interested in including a time-foo.clj following the
> same pattern (append 'time-') in your little library? I've only got
> 'time-let' which is the one I mostly use but I can imagine it shouldn't be
> too hard to do the same on the threading macros, cond etc. Also if I face
> any problems there is always your code to guide me...
>
> Jim
>
>
> On 28/03/13 05:42, Alex Baranosky wrote:
>
> print-foo is a small library useful when debugging code, or at the REPL
> when writing your code.
>
>  https://github.com/AlexBaranosky/print-foo
>
>  It is a collection of macros that mimic basic clojure macros like defn,
> let, or ->, but which prints the value of the code at each point in the
> transformation.  This is more convenient than printlning.  (See the readme
> for a complete list.)
>
>  print-> is especially convenient.
>
>  user=> (print-> 1 inc dec inc dec)1 1inc 2dec 1inc 2dec 11
>
>
>  The only macro in the bunch that is not simply a clojure macro with
> "print-" appended is print-sexp which takes an arbitrary s-expression and
> prints out the values of every sub-sexp, like this:
>
>  user=> (print-sexp (str (+ 3 4) (+ 5 (* 6 2)) 4))(+ 3 4) 7(* 6 2) 12(+ 5 (* 
> 6 2)) 17(str (+ 3 4) (+ 5 (* 6 2)) 4) "7174""7174"
>
> Enjoy :)
> Alex
>  --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>  --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to