2010/12/31 Jarl Haggerty <fictivela...@gmail.com> > I think I asked the wrong question, not only that but I guess I > answered the question I asked, what I want to know is what exactly is > a type hint. I think I've failed to understand exactly what a type > hint is, I assumed to give a hint was to statically type something but > that doesn't seem to be what happens here. > > They are there for helping the compiler generate efficient bytecode for java interop calls (e.g. `(.someMethod anObject ...) calls). Efficient bytecode is bytecode which does not involve the use of reflection at runtime ( e.g. calling getClass().getMethods(), choosing the right method by signature, etc.).
Clojure compiler uses inference to minimize the number of required "type hints". In Clojure 1.3 (not yet stable/released beyond alpha versions), type hints will also be used for generating efficient functions signatures with up to 4 long or double primitive arguments. HTH, -- Laurent > On Dec 30, 9:18 pm, Sunil S Nandihalli <sunil.nandiha...@gmail.com> > wrote: > > I don't think type hints lead to auto casting .. May be somebody else can > > throw more light on it. And it is this way by design. > > Sunil. > > > > On Fri, Dec 31, 2010 at 9:35 AM, Jarl Haggerty <fictivela...@gmail.com > >wrote: > > > > > I have this function > > > > > (defn floor > > > ^int [^float x] x) > > > > > and (floor 1.5) returns 1.5 which confuses me as to how type hints > > > work, I was expecting the result to be truncated or for the program to > > > spit out some exception about expecting an int and getting a float. > > > > > -- > > > 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<clojure%2bunsubscr...@googlegroups.com> > <clojure%2bunsubscr...@googlegroups.com<clojure%252bunsubscr...@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<clojure%2bunsubscr...@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