summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ccwl/utils.scm11
-rw-r--r--tests/utils.scm10
2 files changed, 16 insertions, 5 deletions
diff --git a/ccwl/utils.scm b/ccwl/utils.scm
index c018237..14a3c4d 100644
--- a/ccwl/utils.scm
+++ b/ccwl/utils.scm
@@ -138,12 +138,13 @@ for example, be invoked as:
=> (1 2 123 (1 2 3))
lambda** also supports default values for both unary and n-ary keyword
-arguments. For example,
+arguments. Note that the default value for unary arguments is #f,
+while that for n-ary arguments is the empty list. For example,
-((lambda** (foo aal #:key vale (pal 9) #:key* naal (irandu 7) (sol 3 2 1))
- (list foo aal vale pal naal irandu sol))
+((lambda** (foo bar #:key aal vale (pal 9) #:key* naal (irandu 7) (sol 3 2 1) uruthi)
+ (list foo bar aal vale pal naal irandu sol uruthi))
1 2 #:vale 123 #:naal 321 456)
-=> (1 2 123 9 (321 456) (7) (3 2 1))"
+=> (1 2 #f 123 9 (321 456) (7) (3 2 1) ())"
(syntax-case x ()
((_ (args-spec ...) body ...)
#`(lambda args
@@ -160,7 +161,7 @@ arguments. For example,
(syntax-case x ()
((arg defaults ...)
#'(arg (list defaults ...)))
- (arg #'arg)))
+ (arg #'(arg '()))))
nary-arguments))
body ...)
(let ((positionals rest (break keyword? args)))
diff --git a/tests/utils.scm b/tests/utils.scm
index 5c5bfd1..bc9315d 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -70,6 +70,16 @@
(list foo aal vale pal naal irandu sol))
1 2 #:vale 123 #:naal 321 456))
+(test-equal "default value of lambda** unary argument should be #f"
+ #f
+ ((lambda** (#:key foo)
+ foo)))
+
+(test-equal "default value of lambda** n-ary argument should be the empty list"
+ '()
+ ((lambda** (#:key* foo)
+ foo)))
+
(test-assert "syntax-lambda**"
(equal? (list #'1 #'2 #'123 (list #'1 #'2 #'3))
((syntax-lambda** (a b #:key foo #:key* bar)