summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-12 05:59:41 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-12 05:59:41 -0700
commit000220fca51ff45aeb979ad766667fb3667f0b05 (patch)
tree088f6fef11683e5af043888160f649a2109eed73 /txr.1
parentc8fce379dc53372516766abe5bd8deb9a0f864aa (diff)
downloadtxr-000220fca51ff45aeb979ad766667fb3667f0b05.tar.gz
txr-000220fca51ff45aeb979ad766667fb3667f0b05.tar.bz2
txr-000220fca51ff45aeb979ad766667fb3667f0b05.zip
awk macro: fix: rebind *stdout* in broader scope.
* share/txr/stdlib/awk.tl (sys:awk-state loop): Do not bind *stdout* around the call to the main record-processing function. (awk): Re-bind *stdout* around all of the user code, just after the run-time awk state object is constructed. * txr.1: Correct the lies written about :output.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.153
1 files changed, 42 insertions, 11 deletions
diff --git a/txr.1 b/txr.1
index 62f61fdf..2d8e181d 100644
--- a/txr.1
+++ b/txr.1
@@ -37152,7 +37152,7 @@ with special semantics:
.codn :name ,
.codn :let ,
.codn :inputs ,
-.codn :outputs ,
+.codn :output ,
.codn :begin ,
.codn :end ,
.code :begin-file
@@ -37299,15 +37299,43 @@ of a file to open for writing.
If the
.code :output
-clause is omitted, then the
+clause is omitted, then the current value of the
.code *stdout*
-stream is used as the output.
-
-The output serves the destination for the local
-.code prn
-macro established by the
+stream is used: the value which that special
+variable has on entry into the code generated by the
.code awk
macro.
+
+The
+.code :output
+clause has the effect of creating a local binding for the
+.code *stdout*
+special variable within the dynamic scope of the
+.code awk
+macro. This new value of
+.code *stdout*
+is visible to all forms within the macro.
+If a
+.code :let
+clause is present, it establishes bindings
+in a scope which is nested within the scope established
+by
+.codn :output .
+Therefore,
+.metn init-form -s
+in the
+.code :let
+may refer to the new value of
+.code *stdout*
+established by
+.codn :output .
+Furthermore,
+.code :let
+can rebind
+.codn *stdout* ,
+causing the definition provided by
+.code :output
+to be shadowed.
.meIP (:begin << form *)
All
.code :begin
@@ -37727,12 +37755,15 @@ macro prints lines.
The awk macro
.code prn
performs output into the
-.code awk
-macro's output stream, which may be elected using the
+.code *stdout*
+stream. The
.code :output
-clause.
+clause affects the destination by rebinding
+.codn *stdout* .
-If called with no arguments, it prints
+If called with no arguments,
+.code prn
+prints
.code rec
followed by
.codn ors .