summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-05-24 08:19:14 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-05-24 08:19:14 -0700
commita47eeaf8df2585299844942cbe98b43af4ccc55d (patch)
treee0e7e3d97ab773786eb37c89d803066d2516f4f5 /txr.1
parent35e439fd6d665ff46442463248022a16b259e1a2 (diff)
downloadtxr-a47eeaf8df2585299844942cbe98b43af4ccc55d.tar.gz
txr-a47eeaf8df2585299844942cbe98b43af4ccc55d.tar.bz2
txr-a47eeaf8df2585299844942cbe98b43af4ccc55d.zip
awk: new :fun clause for local functions.
* stdlib/awk.tl (awk-compile-time): New slot, funs. (awk-expander): Gather :fun clauses info funs slot. (awk): Include a labels form which injects the functions. * txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.131
1 files changed, 28 insertions, 3 deletions
diff --git a/txr.1 b/txr.1
index f1d5d6ea..41177693 100644
--- a/txr.1
+++ b/txr.1
@@ -67897,6 +67897,31 @@ and ordinary clauses, it will be shadowed by the
variable
.codn fs ,
which holds the field-separator regular expression or string.
+
+.meIP (:fun >> {( name < param-list << function-body-form *)}*)
+The
+.code :fun
+clause introduces named functions which are visible inside the
+.code awk
+form, as if bound by a
+.code labels
+operator. Variables defined by
+.code :let
+are visible to these named functions. The reverse is not true: the
+functions are not visible to the
+.metn init-form s
+of the
+.code :let
+clause. This is regardless of the order of appearance of the
+.code :let
+and
+.code :fun
+clauses in the
+.code awk
+macro. Furthermore, functions defined by
+.code :fun
+may refer to awk macros, functions and variables.
+
.meIP (:inputs << source-form *)
The
.code :inputs
@@ -69719,10 +69744,10 @@ previously associated stream is used.
The scope of these macros is the entire containing
.code awk
form; they may be used in the
-.metn init-form s
-of the
.code :let
-clause.
+and
+.code :fun
+clauses.
The
.code ->