Start from a main routine: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Changed to Wren S/H)
Line 290: Line 290:


If you want the script to exit even when it hits an error, you can use an [http://www.jsoftware.com/help/dictionary/dx009.htm#26 immex phrase], which will be the first thing executed by the event loop, before it prompts.
If you want the script to exit even when it hits an error, you can use an [http://www.jsoftware.com/help/dictionary/dx009.htm#26 immex phrase], which will be the first thing executed by the event loop, before it prompts.

=={{header|jq}}==

A jq program consists of a (possibly empty) sequence of directives and function definitions followed by a single (but possibly compound) jq expression that is evaluated in the context of the prior definitions. The jq expression can take many forms, such as a single JSON value, or a pipeline of filters. In particular, it could be the invocation of a previously defined function named main as in this example:
<syntaxhighlight lang="jq">
def main:
"Hello, World!";
main
</syntaxhighlight>

The jq interpreter has two modes of operation: a data-driven mode (the default) and an autonomous mode (corresponding to the `-n` command-line option).
In general, in the data-driven mode, the expression at the end of the jq program is evaluated once for each input, so that in the above example,
the "Hello, World!" string would be emitted once for each input.
By contrast, if the `-n` command-line option is specified, then a single JSON `null` would be presented to the final expression, so that in the above example,
the string wold be emitted just once.


=={{header|Julia}}==
=={{header|Julia}}==