diff --git a/module/ice-9/curried-definitions.scm b/module/ice-9/curried-definitions.scm index d7db1f0a8..d55f1fb6a 100644 --- a/module/ice-9/curried-definitions.scm +++ b/module/ice-9/curried-definitions.scm @@ -25,7 +25,9 @@ (lambda rest body body* ...))) ((_ (head . rest) body body* ...) (define head - (lambda rest body body* ...))))) + (lambda rest body body* ...))) + ((_ . rest) + (define . rest)))) (define-syntax cdefine* (syntax-rules () @@ -34,4 +36,6 @@ (lambda* rest body body* ...))) ((_ (head . rest) body body* ...) (define* head - (lambda* rest body body* ...))))) + (lambda* rest body body* ...))) + ((_ . rest) + (define* . rest)))) diff --git a/test-suite/tests/curried-definitions.test b/test-suite/tests/curried-definitions.test index 650288f5c..b4a1f6509 100644 --- a/test-suite/tests/curried-definitions.test +++ b/test-suite/tests/curried-definitions.test @@ -43,4 +43,42 @@ (primitive-eval '(let () (define (((foo)) x) (+ x 34)) - (((foo)) 300)))))) + (((foo)) 300))))) + + (pass-if "just a value" + (equal? 444 + (primitive-eval '(let () + (define foo 444) + foo))))) + +(with-test-prefix "define*" + (pass-if "define* works as usual" + (equal? 34 + (primitive-eval '(let () + (define* (foo) + 34) + (foo))))) + (pass-if "define* works as usual (2)" + (equal? 134 + (primitive-eval '(let () + (define* (foo x) + (+ x 34)) + (foo 100))))) + (pass-if "currying once" + (equal? 234 + (primitive-eval '(let () + (define* ((foo) x) + (+ x 34)) + ((foo) 200))))) + (pass-if "currying twice" + (equal? 334 + (primitive-eval '(let () + (define* (((foo)) x) + (+ x 34)) + (((foo)) 300))))) + + (pass-if "just a value" + (equal? 444 + (primitive-eval '(let () + (define* foo 444) + foo)))))