1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

fix curried definitions for value defines

* module/ice-9/curried-definitions.scm: Allow definitions of values with
  define and define*.
* test-suite/tests/curried-definitions.test: Add tests.
This commit is contained in:
Andy Wingo 2010-04-08 21:01:52 +02:00
parent 1a461493a3
commit e39d0b7668
2 changed files with 45 additions and 3 deletions

View file

@ -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))))

View file

@ -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)))))