Adding if-letk and when-letk macros
RNGMonk opened this issue · 6 comments
Hey guys,
Are there any plans to add these letk variants?
I'd be happy to implement these myself and PR you, but it would be nice if they were included in plumbing.core so that we don't need to use or refer from another namespace.
Cheers,
Mike
Hi Mike,
Sure, we're open to adding them. We actually have when-letk already in our internal plumbing.core-incubator
namespace. Here's the code:
(defmacro when-letk
"bindings => binding-form test
When test is true, evaluates body with binding-form bound to the value of test"
[bindings & body]
(assert (vector? bindings)) "a vector for its binding"
(assert (= 2 (count bindings))) "exactly 2 forms in binding vector"
(let [form (bindings 0) tst (bindings 1)]
`(let [temp# ~tst]
(when temp#
(letk [~form temp#]
~@body)))))
If you want to take a stab at a PR, that would be awesome. Otherwise, we'll get to it when we can.
Thanks!
Jason
Hey Jason,
Ok great, I'd love to take a stab at a PR. Have a great weekend!
Best,
Mike
Great, thanks -- you too!
On Fri, Aug 29, 2014 at 2:02 AM, occamin notifications@github.com wrote:
Hey Jason,
Ok great, I'd love to take a stab at a PR. Have a great weekend!
Best,
Mike—
Reply to this email directly or view it on GitHub
#48 (comment).
Hey Jason,
Here is the PR as promised.
Thanks again to you and the other Prismatic guys for your contributions. I honestly learn a lot just walking through the stuff you guys put out.
Cheers,
Mike
Awesome, thanks for the PR, and for the kind words :)
-Jason
On Wed, Sep 3, 2014 at 11:24 PM, occamin notifications@github.com wrote:
Hey Jason,
Here is the PR #49 as
promised.Thanks again to you and the other Prismatic guys for your contributions. I
honestly learn a lot just walking through the stuff you guys put out.Cheers,
Mike—
Reply to this email directly or view it on GitHub
#48 (comment).