diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-12-30 15:05:30 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-12-30 15:05:30 -0800 |
commit | 4b29e91a09e09ce66060e2be30e1707943e49a85 (patch) | |
tree | 3918df625518aba62a16ef86564efd480c7ce15d /stdlib/awk.tl | |
parent | e4c591c3ff02733fd115343d0212e9083be93b8f (diff) | |
download | txr-4b29e91a09e09ce66060e2be30e1707943e49a85.tar.gz txr-4b29e91a09e09ce66060e2be30e1707943e49a85.tar.bz2 txr-4b29e91a09e09ce66060e2be30e1707943e49a85.zip |
awk: new feature, res variable.
The res variable captures the specific value of the
condition expression, making it available to the action.
* autoload.c (awk_set_entries): Intern the res symbol
* stdlib/awk.tl (awk): Instead of generating the condition-action
into a simple when, we use whenlet to also bind the res variable.
* tests/015/awk-res.tl: New file.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'stdlib/awk.tl')
-rw-r--r-- | stdlib/awk.tl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/stdlib/awk.tl b/stdlib/awk.tl index 87fe96dd..e966b1d1 100644 --- a/stdlib/awk.tl +++ b/stdlib/awk.tl @@ -520,8 +520,10 @@ (defmacro awk (:env outer-env . clauses) (let ((awc (sys:awk-expander outer-env clauses))) (with-gensyms (aws-sym awk-begf-fun awk-fun awk-endf-fun awk-retval) - (let* ((p-actions-xform-unex (mapcar (aret ^(when (sys:awk-test ,@1 rec) - ,*@rest)) + (let* ((p-actions-xform-unex (mapcar (aret + ^(whenlet ((res (sys:awk-test ,@1 + rec))) + ,*@rest)) awc.cond-actions)) (p-actions-xform (expand ^(sys:awk-mac-let ,awc ,aws-sym |