Menu

Comments

Comments in Parsley are annotations in your source code that are ignored by the interpreter. They exist solely for human readers — to explain intent, document behaviour, or temporarily disable code. Parsley supports single-line comments only, using the // prefix.

// This is a comment

Syntax

Single-line comments

A comment begins with // and continues to the end of the line. Everything after // is ignored.

// Calculate the total price including tax
let total = price * 1.2

Inline comments

Comments can appear at the end of a line, after the code:

let rate = 0.05  // 5% interest rate
let years = 10   // Investment period

Multiple comment lines

To write multi-line commentary, use // on each line:

// This function calculates compound interest.
// It takes a principal amount, an annual rate,
// and the number of years.
let compound = fn(principal, rate, years) {
    principal * (1 + rate)  // simplified formula
}

Comments in Different Contexts

Comments work anywhere a line break is valid — at the top of a file, between statements, inside blocks, and alongside tag content:

// Top-level comment
let name = "Basil"

let page = fn() {
    // Inside a function body
    <div>
        // Between tags
        <h1>name</h1>
    </div>
}

No Multi-line Comments

Parsley does not support block comments (/* ... */). If you're coming from C, Java, JavaScript, or Go, this is a deliberate simplification. Use multiple // lines instead.

// ✅ Correct — multiple single-line comments
// This is a longer explanation
// that spans several lines.

// ❌ Wrong — block comments are not supported
// /* This will cause a syntax error */

Shebang Lines

There is one exception to the "no #" rule: a shebang (#!) on the first line of a file is allowed and ignored. This lets you write executable CLI scripts:

#!/usr/bin/env pars
"Hello from a Parsley script"

Make the file executable (chmod +x script.pars) and run it directly (./script.pars).

The exception is deliberately narrow:

  • It only applies to the very first line, and only when the line starts with #!.
  • A # anywhere else — or a # on the first line that isn't followed by ! — is a parse error.
#!/usr/bin/env pars   // ✅ shebang on line 1 — ignored
# a comment           // ❌ parse error: '#' is not a comment character

Key Differences from Other Languages

  • No block comments: There is no /* ... */ syntax — use multiple // lines
  • No doc-comments: There is no /// or /** */ convention — just use //
  • No # comments: Unlike Python, Ruby, or shell scripts, # is not a comment character and will cause a parse error — the sole exception is a #! shebang line at the very top of a file

See Also