Thanks- that worked perfectly. I did not need to extend IFn and I actually got
a runtime error when I tried (perhaps because IFn is a protocol in
ClojureScript?). What are "function"/"object"/ect. in this case,
syntactically? Is there any documentation about this?
Thanks again!
-Scott
--
Extending a protocol to one of the global JS objects is bad for the same reason
it is bad in Javascript: you are modifying a global object. Your
extend-protocol is like saying Function.prototype.FOO_foo = function(this,
arg){...} in javascript. (The "FOO_foo" is a long namespaced and mangled
pr
(defprotocol Foo
(foo [arg]))
(extend-protocol Foo
js/Function
(foo [arg]
(println arg)))
--
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.
Coukd you please post the code that produces that warning? Ideally a
minimal case.
On Thursday, 3 September 2015, Scott Nelson wrote:
> Why is this bad practice? I'm trying to extend a protocol to js/Function
> and I get the following warning:
>
> WARNING: Extending an existing JavaScript type
Why is this bad practice? I'm trying to extend a protocol to js/Function and I
get the following warning:
WARNING: Extending an existing JavaScript type - use a different symbol name
instead of js/Function
I'm trying to create a function that is polymorphic based on the input type
(could be a
This is not a bug as David said.
To expand a little more about why this happens. String.prototype.startsWith is
not part of ES3 or ES5. Only with ES6 will it become standard. The default
language level for the closure compiler is ES3 which is why it doesn't know
startsWith.
You can check the d