Clojure escaped semicolon confused with comment

Issue #387 resolved
Anonymous created an issue

Pygments renders code after a ; as a comment in clojure, which is generally true. But you can also escape the ; like this: \; , which is the character literal for semicolon, and should not produce a comment.

Reported by ericn

Comments (7)

  1. gbrandl

    [relaying comments from OP who has trouble logging in]

    For an explanation of the character escaping:

    http://clojure.org/reader

    Under the literals section.

    On line 76 of this file (part of the main distribution): http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/main.clj

    you will see the semicolon being escaped to indicate a character literal, not a comment.

    I couldn't find anything that said specifically that
    ; has precedence over ; for making comments. But it works in the compiler. It is similar to C where a double slash in a string literal does not start a comment.

  2. thatch

    I couldn't immediately find docs that show this. Could you point me toward them, or toward a real-world example that uses the escaped semicolon?

  3. Anonymous

    Here is a command to generate the problem

    /pygments/pygmentize -l clojure -f html [
    .
    ;
    .
    .
    p] ^D

    <div class="highlight"><pre><span class="p">[</span><span class="sc">
    .</span> <span class="err">
    </span><span class="c1">;
    .
    .
    p]</span> </pre></div>

  4. Log in to comment