Comments

Luma supports simple and clean commenting, helping you document your code without clutter or confusion.

Single-line comments

Use // for comments, similar to languages like Go, JavaScript and C++. Everything from // to the end of the line is ignored.

// This is a single-line comment
name: str = "Luma" // You can also comment after a statement
print(name)

Output:

Luma

Multi-line comments

Luma does not use /* ... */ for multi-line comments. Instead, write several // lines:

// This is a longer explanation
// that spans multiple lines
// and remains readable and clear.
greeting: str = "Hi"

Writing /* is an error that reminds you of this:

x: int = 1 /* old style */   // error: Luma has no /* */ comments; start each comment line with //

Why this approach?

  • Cleaner parsing: it avoids the complexity of nested /* ... */.
  • Better version control diffs: every commented line is visible on its own in a diff.
  • Editor-friendly: it matches the line-comment shortcut of most editors.

Where comments can go

A comment can go on its own line or after a statement, including inside multi-line lists, maps and sets, and after { or }:

nums: [int] = [
    1, // first
    // a whole line inside a list
    2,
]
if len(nums) > 1 { // after a brace
    print(nums)
} // after the closing brace

Output:

[1, 2]

Inside a string, // is ordinary text:

print("https://luma.tarkvara.ee // not a comment")

Output:

https://luma.tarkvara.ee // not a comment

Comments that describe a type

The comments of an obj are kept for schema: the comment on a field’s line and the comment lines right above it describe the field, and the comment right above obj describes the type. An AI model reads them when it fills the fields.

// A city's weather, as a tool's input.
obj Weather {
    // the city's name,
    // e.g. Tartu
    city: str
    days: int = 1      // how many days ahead
}

print(schema(Weather))

Output:

{"type":"object","description":"A city's weather, as a tool's input.","properties":{"city":{"type":"string","description":"the city's name, e.g. Tartu"},"days":{"type":"integer","description":"how many days ahead"}},"required":["city"],"additionalProperties":false}

Several comment lines are joined with spaces. A blank line between a comment and what follows means it describes nothing.

Best practices

  • Use comments to explain why, not what.
  • Keep them short, focused and consistent.
  • Use them to separate logic or highlight edge cases.
// Retry limit agreed with the server team: more would trigger rate limiting
retries: int = 3

// Only admins may change settings
role: str = "admin"
if role == "admin" {
    // Allow access
    access: bool = true
}