summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2021-07-20 16:32:50 +0530
committerArun Isaac2021-07-20 16:32:50 +0530
commit54d5ce4ecdc414c74afd3cf2b37fbebb82c3cc81 (patch)
treeb7623e765390c5a9b7f3a365985ae58c30885c7c
parent308bc011949752f0b452dac5081814674d73f62a (diff)
downloadccwl-54d5ce4ecdc414c74afd3cf2b37fbebb82c3cc81.tar.gz
ccwl-54d5ce4ecdc414c74afd3cf2b37fbebb82c3cc81.tar.lz
ccwl-54d5ce4ecdc414c74afd3cf2b37fbebb82c3cc81.zip
ccwl: Document syntax-lambda** support for default arguments.
* ccwl/utils.scm (syntax-lambda**): Add example to docstring documenting support for default arguments. * tests/utils.scm ("syntax-lambda** with default values"): New test.
-rw-r--r--ccwl/utils.scm10
-rw-r--r--tests/utils.scm6
2 files changed, 15 insertions, 1 deletions
diff --git a/ccwl/utils.scm b/ccwl/utils.scm
index 067308f..c018237 100644
--- a/ccwl/utils.scm
+++ b/ccwl/utils.scm
@@ -183,7 +183,15 @@ writing macros that accept keyword arguments. For example,
((syntax-lambda** (a b #:key foo #:key* bar)
(list a b foo bar))
#'(foo 1 2 #:foo 123 #:bar 1 2 3))
-=> (#'1 #'2 #'123 (#'1 #'2 #'3))"
+=> (#'1 #'2 #'123 (#'1 #'2 #'3))
+
+Just like lambda**, syntax-lambda** also supports default values for
+arguments. For example,
+
+((syntax-lambda** (foo aal #:key vale (pal 9) #:key* naal (irandu 7) (sol 3 2 1))
+ (list foo aal vale pal naal irandu sol))
+ #'(bar 1 2 #:vale 123 #:naal 321 456))
+=> (#'1 #'2 #'123 9 (#'321 #'456) (7) (3 2 1))"
(lambda (x)
(apply (lambda** formal-args body ...)
(with-ellipsis :::
diff --git a/tests/utils.scm b/tests/utils.scm
index 473bd45..5c5bfd1 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -76,6 +76,12 @@
(list a b foo bar))
#'(foo 1 2 #:foo 123 #:bar 1 2 3))))
+(test-assert "syntax-lambda** with default values"
+ (equal? (list #'1 #'2 #'123 9 #'(321 456) '(7) '(3 2 1))
+ ((syntax-lambda** (foo aal #:key vale (pal 9) #:key* naal (irandu 7) (sol 3 2 1))
+ (list foo aal vale pal naal irandu sol))
+ #'(bar 1 2 #:vale 123 #:naal 321 456))))
+
(test-equal "filter-mapi"
'(1 3 5 7 9)
(filter-mapi (lambda (item index)