Yeah, cond will probably do the trick as well.

I do consider if complex (and yeah my argument is true for a lot of
functions)
What i'm talking about is some accidental complexity of the language. That
I must constantly be aware of what parameter of the function I'm looking
at.

My point is not so much the order (but I did it anyway to take even more
complexity) of then, else but the fact that when looking at longer pieces
of code I cannot immediately see whether i'm looking at the then branch er
else branch. Mostly i must rely on intendations, which makes everything
more complex.

So, I saw the ideal opportunity to write my first macro. In my opinion it
makes it simpler. But then again, cond seems to accomplish my goal already
:-)


On Sun, Dec 9, 2012 at 5:14 PM, Jozef Wagner <jozef.wag...@gmail.com> wrote:

> How about cond?
>
> (cond
>   test true
>   :else false)
>
> BTW I personally don't consider if complected. If reverse order is more
> appropriate, I use if-not.
>
> On Sunday, December 9, 2012 12:02:54 AM UTC+1, Thomas Goossens 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 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
>



-- 
Thomas Goossens

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