My guess: to allow functions with :inline metadata to still be used as
higher order (first class) functions.

Note, the fn specified by :inline is more of a macro than a function, it's
called at compile time.

How would the following work without a function body?

(map pos? [-1 0 1])

definline gives you what you're asking for, a way to define an :inline
function without repetition.

--Aaron

On Sun, Jul 15, 2012 at 10:43 PM, dennis zhuang <killme2...@gmail.com>wrote:

> Inline a function in clojure is easy,just define a :inline form to meta
> map and it will be inlined into the form which calls it.For example,the
> pos? function in clojure.core:
>
> (defn pos?
>
>   "Returns true if num is greater than zero, else false"
>
>   {
>
>    :inline (fn [x] *`(. clojure.lang.Numbers (isPos ~x))*)
>
>    :added "1.0"}
>
>   [x] *(. clojure.lang.Numbers (isPos x))*)
>
>
> But i have a question about the usage,why we have to write the body
> form(Here is *(. clojure.lang.Numbers (isPos ~x))*) twice both in
> function's body and :inline value? Why :inline form could not just use the
> form in function's body instead of duplicate definition?
>
>
> --
> 庄晓丹
> Email:        killme2...@gmail.com xzhu...@avos.com
> Site:           http://fnil.net
> Twitter:      @killme2008
>
>
>
>  --
> 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 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