diff options
| -rw-r--r-- | ccwl/utils.scm | 31 | ||||
| -rw-r--r-- | tests/utils.scm | 20 |
2 files changed, 16 insertions, 35 deletions
diff --git a/ccwl/utils.scm b/ccwl/utils.scm index 3dc7f4b..5d53639 100644 --- a/ccwl/utils.scm +++ b/ccwl/utils.scm @@ -152,15 +152,6 @@ arguments. Note that the default default value for unary arguments is 1 2 #:vale 123 #:naal 321 456) => (1 2 #f 123 9 (321 456) (7) (3 2 1) ()) -Like lambda*, lambda** supports #:allow-other-keys. For example, - -((lambda** (#:key foo #:allow-other-keys) - foo) - #:foo 1 #:bar 2) -=> 1 - -However, #:optional and #:rest are not supported. - If an unrecognized keyword is passed to the lambda function, a &unrecognized-keyword-assertion condition is raised. If a unary keyword argument is passed more than one argument, a @@ -177,9 +168,7 @@ However these exceptions are continuable." (unary-arguments (or (plist-ref grouped-rest #:key) (list))) (nary-arguments (or (plist-ref grouped-rest #:key*) - (list))) - (allow-other-keys? (if (plist-ref grouped-rest #:allow-other-keys) - #t #f))) + (list)))) (let ((unrecognized-keywords (lset-difference (lambda (x y) (let ((x (if (keyword? x) x (syntax->datum x))) @@ -187,7 +176,7 @@ However these exceptions are continuable." (eq? x y))) (filter (compose keyword? syntax->datum) #'(args-spec ...)) - (list #:key #:key* #:allow-other-keys)))) + (list #:key #:key*)))) (unless (null? unrecognized-keywords) (raise-continuable (condition (unrecognized-keyword-assertion) @@ -200,9 +189,7 @@ However these exceptions are continuable." #'(arg (list defaults ...))) (arg #'(arg '())))) nary-arguments) - (if allow-other-keys? - (list #:allow-other-keys) - (list))) + (list #:allow-other-keys)) body ...) (let ((positionals rest (break keyword? args))) ;; Test for correct number of positional @@ -223,8 +210,7 @@ However these exceptions are continuable." (arg #'arg))))) (append unary-arguments nary-arguments))))) - (unless (or #,allow-other-keys? - (null? unrecognized-keywords)) + (unless (null? unrecognized-keywords) (raise-continuable (condition (unrecognized-keyword-assertion) (irritants-condition unrecognized-keywords))))) @@ -255,15 +241,6 @@ that for n-ary arguments is the empty list. For example, #'1 #'2 #'#:vale #'123 #'#:naal #'321 #'456) => (#'1 #'2 #'123 9 (#'321 #'456) (7) (3 2 1)) -Like lambda**, syntax-lambda** supports #:allow-other-keys. - -((syntax-lambda** (#:key foo #:allow-other-keys) - foo) - #'#:foo #'1 #'#:bar #'2) -=> #'1 - -#:optional and #:rest are not supported. - If an unrecognized keyword is passed to the lambda function, a &unrecognized-keyword-assertion condition is raised. If a unary keyword argument is passed more than one argument, a diff --git a/tests/utils.scm b/tests/utils.scm index f3d9abd..7ca73b8 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -89,11 +89,13 @@ '(lambda** (#:key foo #:foo bar) foo)))) -(test-equal "Allow other keys in lambda**" +(test-equal "Allow other keys in lambda**, but raise an exception" 1 - ((lambda** (#:key foo #:allow-other-keys) - foo) - #:foo 1 #:bar 2)) + (with-exception-handler (const #t) + (lambda () + ((lambda** (#:key foo) + foo) + #:foo 1 #:bar 2)))) (test-assert "Unrecognized keyword argument passed to lambda** should raise an &unrecognized-keyword-assertion condition" (guard (exception @@ -138,11 +140,13 @@ ((syntax-lambda** (#:key* foo) foo))) -(test-equal "Allow other keys in syntax-lambda**" +(test-equal "Allow other keys in syntax-lambda**, but raise an exception" 1 - (syntax->datum ((syntax-lambda** (#:key foo #:allow-other-keys) - foo) - #'#:foo #'1 #'#:bar #'2))) + (syntax->datum (with-exception-handler (const #t) + (lambda () + ((syntax-lambda** (#:key foo) + foo) + #'#:foo #'1 #'#:bar #'2))))) (test-assert "syntax-lambda** should raise an &unrecognized-keyword-assertion on unrecognized keywords in arguments" (guard (exception |
