Hi Marc,
This isn't an interop issue but simply is arising from the fact that you
are attempting to call a string as though it were a function, and it is
getting caught at runtime.
To compare, I tried the same code in ClojureScript and I saw: "Uncaught
TypeError: undefined is not a function" which is roughly the same
(although I'm a bit surprised by the "undefined" and would have expected
that to be a string).
In any case, I'm not sure what your original goal was, but maybe this
was what you were looking for?
> (map #(name (key %)) f)
That is, you don't need to wrap this in a call to 'str,' name already
returns a string.
DD
On 2015/02/17 11:15, Marc Fawzi wrote:
> As a new user to ClojureScript who has not programmed in Clojure or any
> JVM-to-JS environment this comes to me as a huge surprise!
>
> (it shouldn't if I had thought things more deeply, but don't have the
> luxury of infinite ramp up time)
>
> user=> (def f {"a" "1" "b" "2"})
>
> user=> (map #((name (key %))) f)
>
> ClassCastException java.lang.String cannot be cast to clojure.lang.IFn
> user/eval1212/fn--1213 (b43f5f5d46b2bd87480559901c3a9d087879416a-init.clj:1)
>
>>>> Is that a Java/Clojure Interop error? I suppose if the REPL throws
> then I'll also see this error or a variant of it IN THE BROWSER ?
>
> The error is resolved if I do this
>
> (map #(str (name (key %))) f)
>
> I thought Clojure is dynamically typed and I understand for Java interop
> on the server if we have to do this but why couldn't we get away with it
> in the browser environment?
>
> My limited understanding is that str here is like String(val) in JS,
> which is almost never needed.
>
>
> Please enlighten, whomever understands the interop stuff and why as
> front end developers we have to carry that burden?
>
>
>
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google
> Groups "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/clojurescript.
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.