diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-02-06 00:41:40 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-02-06 00:41:40 -0800 |
commit | 4104aedd5d1924ac52e5be8e05a2eb179ce4320e (patch) | |
tree | f95460cfc9b355f66f8a26c50ba655287c56e071 /share | |
parent | 72e321922b438c58285314c5c816b211cdec70ef (diff) | |
download | txr-4104aedd5d1924ac52e5be8e05a2eb179ce4320e.tar.gz txr-4104aedd5d1924ac52e5be8e05a2eb179ce4320e.tar.bz2 txr-4104aedd5d1924ac52e5be8e05a2eb179ce4320e.zip |
matcher: left-to-right scoping for @(and).
And binds left to right now; only or is parallel.
* share/txr/stdlib/match.tl (compile-and-mach): Do not compile
the patterns with copies of the var list, but with he one and
only incoming var-list. Consequently, there are not var lists
to merge. par-pat parameter renamed to and-pat.
* txr.1: Improve and/or documentation, clarifying scope
rules. Also, clarify that variables in non-matching patterns
of an or are no set to nil, if they are existing bindings from
before the or.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/match.tl | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index ea0134fc..f99a8fe6 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -446,15 +446,11 @@ obj-var obj-var guard-chain (list dj-guard))))) -(defun compile-and-match (par-pat obj-var var-list) - (mac-param-bind *match-form* (op . pats) par-pat - (let* ((var-lists (mapcar (ret (copy var-list)) pats)) - (par-matches (mapcar (op compile-match @1 obj-var @2) - pats var-lists))) - (each ((vl var-lists)) - var-list.(merge vl)) +(defun compile-and-match (and-pat obj-var var-list) + (mac-param-bind *match-form* (op . pats) and-pat + (let* ((par-matches (mapcar (lop compile-match obj-var var-list) pats))) (new compiled-match - pattern par-pat + pattern and-pat obj-var obj-var guard-chain (mappend .guard-chain par-matches))))) |