Nice :)

On Sunday, December 9, 2012 1:17:48 AM UTC+1, Michał Marczyk wrote:
>
> Better yet, 
>
> (defmacro iff [test & {:keys [then else]}] 
>   `(if ~test ~then ~else)) 
>
> (that's doing the lookup for then and else in the map constructing 
> from the macro's rest argument at compilation time rather than in an 
> evaluated map including both at run time). 
>
> Cheers, 
> Michał 
>
>
> On 9 December 2012 00:40, Ben Wolfson <wol...@gmail.com <javascript:>> 
> wrote: 
> > You may want to use some delays to prevent evaluation of untaken 
> branches: 
> > 
> > user=> (iff true :else (println 1) :then (println 3)) 
> > 3 
> > 1 
> > nil 
> > user=> 
> > 
> > 
> > On Sat, Dec 8, 2012 at 3:02 PM, Thomas Goossens 
> > <con...@thomasgoossens.be <javascript:>> wrote: 
> >> One of the issues i had and still have with the if function  is that 
> >> because it has ordered arguments, makes things more complex. 
> >> 
> >> For small functions this is no so much of a problem. 
> >> (if test 1 0) 
> >> 
> >> But when things get larger,  that extra complexity of order without 
> explicit 
> >> information can get significant, I believe 
> >> 
> >> So I wanted (this would be officially my first macro ever!) something 
> that 
> >> behaved as follows: 
> >> 
> >> (if test 
> >>  :then true 
> >>  :else false) 
> >> 
> >> (if test 
> >>  :else false 
> >>  :then true) 
> >> 
> >> Which is what I eventually did: 
> >> 
> >> (defmacro iff 
> >>   [test & body] 
> >>   (let [args (apply hash-map body)] 
> >>       `(if ~test (:then ~args) (:else ~args)))) 
> >> 
> >> Any thoughts, improvements on my macro? (Also I'm not quite sure how to 
> >> document my macro. So any advice on that is appreciated :) 
> >> 
> >> 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> >> Groups "Clojure" group. 
> >> To post to this group, send email to clo...@googlegroups.com<javascript:> 
> >> Note that posts from new members are moderated - please be patient with 
> your 
> >> first post. 
> >> To unsubscribe from this group, send email to 
> >> clojure+u...@googlegroups.com <javascript:> 
> >> For more options, visit this group at 
> >> http://groups.google.com/group/clojure?hl=en 
> > 
> > 
> > 
> > -- 
> > Ben Wolfson 
> > "Human kind has used its intelligence to vary the flavour of drinks, 
> > which may be sweet, aromatic, fermented or spirit-based. ... Family 
> > and social life also offer numerous other occasions to consume drinks 
> > for pleasure." [Larousse, "Drink" entry] 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com<javascript:> 
> > Note that posts from new members are moderated - please be patient with 
> your first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com <javascript:> 
> > 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 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