diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-02-04 01:43:20 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-02-04 01:43:20 -0800 |
commit | 8132c60cdb613e27eb2b8e58b8d1ea9ae01a615c (patch) | |
tree | 62d32a6245964cb20ed4febfa743afd3862c4b3e /share | |
parent | 8bc0ac3a54d248ba2d4a8a045dc2bc0619a60886 (diff) | |
download | txr-8132c60cdb613e27eb2b8e58b8d1ea9ae01a615c.tar.gz txr-8132c60cdb613e27eb2b8e58b8d1ea9ae01a615c.tar.bz2 txr-8132c60cdb613e27eb2b8e58b8d1ea9ae01a615c.zip |
matcher: lambda-match: redoc, bugfix, test-cases
* share/txr/stdlib/match.tl (expand-lambda-match): In a case
that takes the maximum number of fixed args and no dotted
pattern, in a function that is variadic, we must assert that
the rest parameter is nil: there are no additional arguments.
In the lambda args, we must generate the colon that separates
the optional arguments.
* tests/011/patmatch.tl: basic test cases for lambda-match
and defun-match.
* txr.1: lambda-match and defun-match redocumented, with
examples.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/match.tl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index e2e1ac4a..e2a55256 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -656,11 +656,16 @@ (when (< pc.nfixed max-args) (set exp ^(unless ,[present-vec pc.nfixed] ,exp))) + (when (and variadic (not vp) (= pc.nfixed max-args)) + (set exp ^(unless ,rest-temp + ,exp))) (unless (zerop counter) (set exp ^(unless ,result-temp ,exp))) exp)))) ^(lambda (,*fix-arg-temps - ,*(mapcar (ret ^(,@1 nil ,@2)) opt-arg-temps present-p-temps) + ,*(if opt-arg-temps + (cons : (mapcar (ret ^(,@1 nil ,@2)) + opt-arg-temps present-p-temps))) . ,rest-temp) (let (,matched-p-temp ,result-temp) ,*ex-clauses |