Hi,
Am 28.12.2011 um 10:32 schrieb liulei:
> I write one function,example:
>
> (defn #^{:return String} shout [#^{:tag String} s #^{:tag String} s1]
> (.toUpperCase s))
>
> The function has two parameters: s and s1, I hope the two parameters
> are both String type.
> But I run the command: (shout "1" 2), the command print "1", why
> the command don't throw ClassCastException?
Because the second parameter is not used. Clojure is not statically typed.
Hence the types are not checked. However hinting them will emit bytecode with
the class wired in. When you then use the parameter in interop (like the first
one in your example) it will fail. If you do only Clojure things or don't use
the parameter, you won't get an error.
Sincerely
Meikel
--
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