Type tagging short-form is not highlighted properly

Create issue
Issue #89 resolved
Gianni Chiappetta created an issue

Example: ^String or ^symbol both look out of place when highlighted, also highlighted inconsistently.

Screenshot: http://cloud.gf3.ca/Cz6R

Comments (2)

  1. Meikel Brandmeyer repo owner
    • changed status to open
    • changed version to v2.3

    Yes. The ^ is not highlighted correctly.

    However, the highlighting of symbol is correct. symbol is a core function. Not a class. So the code in the screenshot will likely not work correctly.

    user=> (defn ^symbol foo [] 'x)
    user=> (.toString (foo))
    CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: clojure.core$symbol@73eb904d, compiling:(NO_SOURCE_PATH:4) 
    user=> (defn ^clojure.lang.Symbol bar [] 'x)
    user=> (.toString (bar))

    In general I would recommend to not use type hints at all. They are only needed when you use Java interop directly. And even then they could be left out if performance was not an issue. Otherwise you tie your code needlessly to specific classes. For example CharSequence works fine on the JVM, but maybe not on the CLR while the code would work perfectly fine on both platforms.

  2. Log in to comment