Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pragmas

Pragmas control various language features and appear in a declaration block so their effect is lexically scoped. They have the form

pragma <id> = <expr>

where <id> is an identifier and <expr> is a constant expression that must evaluate at compile time without referencing any runtime state such as this or a field of this.

Pragmas must appear in the declaration section of a scope.

List of Pragmas

Currently, there is just one supported pragma.

Example


Controlling indexing and slicing

# spq
pragma index_base = 1
values {
  a: this[2:3],
  b: (
    pragma index_base = 0
    values this[0]
  )
}
# input
"bar"
[1,2,3]
# expected output
{a:"a",b:error("missing")}
{a:[2],b:1}