On 1/26/12 5:07 AM, Cedric Greevey wrote:
On Thu, Jan 26, 2012 at 5:54 AM, Tassilo Horn<tass...@member.fsf.org> wrote:
Cedric Greevey<cgree...@gmail.com> writes:
On Thu, Jan 26, 2012 at 2:28 AM, Tassilo Horn<tass...@member.fsf.org> wrote:
At least, it seems that (fn ^double [^double x] (+ x 0.5)) compiles to a
class supporting primitive, unboxed calls.
Yes. That was my conclusion also. But apparently the only way to get
the compiler to emit such a call is by binding the fn to a global Var
with the appropriate hints and calling that.
Yeah, I know. And now I can also see it in the Compiler's InvokeExpr
class. In its constructor, there's some extra work in case of a VarExpr
where the signature :tag metadata is pulled out from the :arglists
metadata.
Why is the :arglists metadata added to the Var a function's bound to
instead of the function itself?
AFAICT, the compiler will need to know the call is definitely
primitive and the fn is definitely primitive-compatible at compile
time if it is to safely emit a primitive call. This is why I tried a
^Ifn$DD hint on the variable at one point.
When the fn comes from a non-dynamic Var the compiler can easily be
sure what primitive signatures it supports.
When the fn is potentially runtime-variable, it seems to me that a
hint on the local *should* suffice, and type inference from
assignments *should* be possible, as it is for locals assigned
primitive values. (If the hint was wrong, you'd get runtime
ClassCastExceptions such as my_ns.my_defn$fn_3072 cannot be cast to
clojure.lang.IFn$DD, much as you can get various CCEs with incorrect
(reference) type hints elsewhere.) However, this seems to be either
broken or not implemented yet.
Should a ticket be created for this then?
--
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