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
The hints are not use for static type analysis they are there for
speed. There is no type checker. In your example the compiler tries
using it as an int if that is not working the compiler uses reflaction
to find out the type.
no auto casts are by design.
On 31 Dez., 05:57, Jarl Haggerty
In Clojure 1.2, type hints only help the compiler avoid reflection and thus
generate faster Java interop code.
Starting in 1.3, function arguments and return values can have ^long or
^double type hints (int and float are not supported). These are enforced at
compile time, but they are not
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
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.comwrote:
I have this function
(defn floor
^int [^float x] x)
and (floor 1.5) returns
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