On Mon, Jul 16, 2012 at 11:26 AM, dennis zhuang <[email protected]> wrote:
>
> Yes, thank you for your reply,i total agree with you about why we need 
> :inline form in meta map.
> But my problem is that why clojure compiler could not use the body form as 
> the :inline value automatically for us instead of writing a duplicate form? I 
> think below codes is more suitable:

> (defn pos?
>   "Returns true if num is greater than zero, else false"
>   {
>    :inline true
>    :added "1.0"}
>   [x] (. clojure.lang.Numbers (isPos x)))
>
>
> Then clojure compiler finds out that we set :inline to be true and captures 
> the body form as the :inline value automatically,is it not better?
>
> If the function accepts different arguments arities, we can set 
> :inline-arities value to make compiler captures the body form  which 
> arguments count equals to :inline-arities value as :inline value.
>

As I said, that's precisely what definline does. As many things in
clojure, the simple pieces are given and "easy" things can be built on
top of them. I don't know precisely when in clojure.clj that "pos?" is
defined, but if it is late enough that "definline" has been defined,
it could be rewritten as:

(definline pos?
    "Returns true if num is greater than zero, else false"
    {:added "1.0"}
   [x] `(. clojure.lang.Numbers (isPos x)))

Which is pretty much what you asked for, isn't it?

The fact that it isn't written that way is either historical or
because it needs to exist before definline does.

--Aaron

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to