Literal values

Some of the Patchworks Query Language functions require literal values for some their arguments, and the requirement for literal values will be noted in the function documentation. But what is a literal value in the Patchworks Query Language?

Literals are fixed values, such as constant numbers or strings. A literal string, for example, is a string value surrounded by single quotes (e.g. 'hello world'). Query Language expressions can also be effectively literal if all of the inputs to the expression are literal. For example, the following expression contains only literal values and can be resolved unequivocally to a final literal value when the expression is parsed:


Some functions are effectively literal because the values that they return are know at parse time. For example the getEnv function is literal for repeat and system environment variables, because these values are known are parse time. getEnv values for report variables are not literal, because these are set at runtime.

Database variables are never literal, nor are functions that depend on the context, such as offset, period, row, and year.

Many functions are effectively literal if they are provided with literal arguments.

The curvenames function is resolved to a literal at parse time with the set of all curves that have been defined up until that point in operations. If curves are subsequently added to the curve library they will not be noticed by previous invocations of curveNames().

When literal values are encountered the Query Language compiler will perform constant folding and elimination of effectively final functions and operators, resulting in a compact and efficient executable expression. During runtime the Java "Just In Time" compiler with perform profiling, inlining and compilation to produce highly optimized machine code resulting in excellent runtime performance.