On Thu, 28 Oct 2010 18:12:39 -0700 (PDT)
andrei <andrei.zhabin...@gmail.com> wrote:
> 
> I'll try to extend Mike's answer by one more example. Consider `and`
> Lisp macro. It is not a function, because it must evaluate it's
> arguments lazily, and using macros is the only way to do it.

Actually, this is the first case, and a classic example of it: you
need to control how many times the arguments are evaluated.

> But try
> to apply `and` to the list of values (I know, that it's a job for a
> function `every?`, but how will you implement this function itself?):
> 
> (apply and (list true true false true))   ==> error

And this is the issue of not being able to pass macros to higher order
functions.

> You cannot do it, since and is not a function. So, you need to use
> wrapper around `and`:
> 
> (reduce #(and %1 %2) (list true true false true))  ==> false
> 
> And this is still not the perfect solution, since it is not lazy.
> 
> So you can see both advantages and disadvantages of using macros.

Which is why you only want to use them when you have to. If you don't
need the advantages, why put up with the disadvantages?

     <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

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