diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-08-08 07:53:43 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-08-08 07:53:43 -0700 |
commit | 3c0c679b74016f0219c31d82578b99e53e531c78 (patch) | |
tree | 36790f5703b5100a890056b91f4216ce501ac123 /stdlib/op.tl | |
parent | ca9ecd3ded67f06c9cebe5b3fd4d6fb940342f44 (diff) | |
download | txr-3c0c679b74016f0219c31d82578b99e53e531c78.tar.gz txr-3c0c679b74016f0219c31d82578b99e53e531c78.tar.bz2 txr-3c0c679b74016f0219c31d82578b99e53e531c78.zip |
new: left-inserting pipeline operators.
* stdlib/op.tl (opip-expand): Take arguments which specify
the op and do operators to be inserted. Pass these
through the recursive calls.
(opip, oand): Pass op and do for the new arguments.
(lopip, loand): New macros like opip and oand, but
passing lop and ldo to the expander.
(lflow): New macro.
* autoload.c (op_set_entries): Add autoload entries
for lopip, loand and lflow.
* tests/012/op.tl: A few new tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Regenerated.
Diffstat (limited to 'stdlib/op.tl')
-rw-r--r-- | stdlib/op.tl | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/stdlib/op.tl b/stdlib/op.tl index 2a41fc5a..4b5b0311 100644 --- a/stdlib/op.tl +++ b/stdlib/op.tl @@ -231,32 +231,42 @@ (listp rest))) (t nil))) -(defun sys:opip-expand (e clauses) +(defun sys:opip-expand (e opsym dosym clauses) (tree-case clauses (nil nil) ((c . rest) (if (atom c) - (cons c (sys:opip-expand e rest)) + (cons c (sys:opip-expand e opsym dosym rest)) (let ((sym (car c))) (cond ((memq sym '(dwim uref qref op do lop ldo ap ip ado ido ret aret)) - (cons c (sys:opip-expand e rest))) + (cons c (sys:opip-expand e opsym dosym rest))) ((sys:opip-single-let-p c) (tree-bind (t sym) c - (sys:opip-expand e ^((let (,sym @1)) ,*rest)))) + (sys:opip-expand e opsym dosym ^((let (,sym @1)) ,*rest)))) ((sys:opip-let-p c) (tree-bind (t . vars) c ^((do let* ,vars - [(opip ,*(sys:opip-expand e rest)) @1])))) + [(opip ,*(sys:opip-expand e opsym dosym rest)) @1])))) (t (let ((opdo (if (or (special-operator-p (car c)) - (macro-form-p c e)) 'do 'op))) - (cons ^(,opdo ,*c) (sys:opip-expand e rest)))))))))) + (macro-form-p c e)) dosym opsym))) + (cons ^(,opdo ,*c) (sys:opip-expand e opsym dosym + rest)))))))))) (defmacro opip (:env e . clauses) - ^[chain ,*(sys:opip-expand e clauses)]) + ^[chain ,*(sys:opip-expand e 'op 'do clauses)]) (defmacro oand (:env e . clauses) - ^[chand ,*(sys:opip-expand e clauses)]) + ^[chand ,*(sys:opip-expand e 'op 'do clauses)]) + +(defmacro lopip (:env e . clauses) + ^[chain ,*(sys:opip-expand e 'lop 'ldo clauses)]) + +(defmacro loand (:env e . clauses) + ^[chand ,*(sys:opip-expand e 'lop 'ldo clauses)]) (defmacro flow (val . opip-args) ^(call (opip ,*opip-args) ,val)) + +(defmacro lflow (val . opip-args) + ^(call (lopip ,*opip-args) ,val)) |