3 ms·
TXR Lisp provides a Lisp-ified awk in a macro: http://www.nongnu.org/txr/txr-manpage.html#N-000264BC http://www.nongnu.org/txr/txr-manpage.html#N-000264BC > "
by kazinator 9y ago
TXR Lisp provides a Lisp-ified awk in a macro:
http://www.nongnu.org/txr/txr-manpage.html#N-000264BC http://www.nongnu.org/txr/txr-manpage.html#N-000264BC
> "Unlike Awk, the awk macro is a robust, self-contained language feature which can be used anywhere where a TXR Lisp expression is called for, cleanly nests with itself and can produce a return value when done. By contrast, a function in the Awk language, or an action body, cannot instantiate an local Awk processing machine. "
The manual contains a translation of all of the Awk examples from the POSIX standard:
http://www.nongnu.org/txr/txr-manpage.html#N-03D16283 http://www.nongnu.org/txr/txr-manpage.html#N-03D16283
The (-> name form ...) syntax above is scoped to the surrounding awk macro. Like in Awk, the redirection is identified by string. If multiple such expressions appear with the same name, they denote the same stream (within the lexical scope of the awk macro instance to which they belong). These are implicitly kept in a hash table. When the macro terminates (normally or via non-local jump like an exception), these streams are all closed.