ClojureScript

Unexpected behavior with dispatch on Keyword via protocols

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

At the moment if you create a protocol and expect it to be able to dispatch on keywords you need to do it in js/String, trying to extend on cljs.core.Keyword doesn't work as keywords are just Strings.

See https://gist.github.com/4104635

Activity

Hide
David Nolen added a comment -

Made moot by CLJS-576

Show
David Nolen added a comment - Made moot by CLJS-576
Hide
Max Penet added a comment -

Thanks for the pointer about default and string, I didn't know about that.

I reported the issue at the demand of bbloom. It does seem to be difficult to address without taking a (major) performance hit unfortunately.

Show
Max Penet added a comment - Thanks for the pointer about default and string, I didn't know about that. I reported the issue at the demand of bbloom. It does seem to be difficult to address without taking a (major) performance hit unfortunately.
Hide
David Nolen added a comment -

This is a known issue which will have to wait for if and when Keywords and Symbols become proper types in ClojureScript.

Extending js/Object is not recommended, if you actually need to add functionality to the base JS native types the convention is different from Clojure: default instead of Object, string instead of js/String. Please refer to core.cljs if you want more examples.

Show
David Nolen added a comment - This is a known issue which will have to wait for if and when Keywords and Symbols become proper types in ClojureScript. Extending js/Object is not recommended, if you actually need to add functionality to the base JS native types the convention is different from Clojure: default instead of Object, string instead of js/String. Please refer to core.cljs if you want more examples.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: