Scripts
The q session is a REPL. It evaluates an expression and displays its result. It doesn’t allow for continuation lines.
A lambda defined in the session may include multiple expressions but can be written only on a single line.
This is not the case for scripts.
- Script
-
A text file containing a sequence of expressions separated by single or multiple linebreaks.
In a script, an expression is terminated by a linebreak followed by either a linebreak or a non-whitespace character.
tbl: select from table
by exchange
where sym in `ibm`goog
A single space suffices to indent a continuation line. For clarity, two are recommended.
Script expressions are not separated by trailing semicolons.
Semicolons at the end of script expressions are redundant. Worse, they obscure semicolons that separate expressions within a lambda definition or an argument list.
A valid use case is to suppress output to stdout:
`b`c set' a+10 1000;
Otherwise remove them!
It follows that in a script you can write a lambda across multiple lines.
Invocation
You can invoke a script with the \l
system command:
q)\l util.q
or as a parameter in the OS command shell:
> q util.q