mirror of
https://https.git.savannah.gnu.org/git/guix.git/
synced 2025-07-13 18:40:57 +02:00
define-record-type*: Add `letrec*' behavior.
* guix/utils.scm (define-record-type*)[make-syntactic-constructor]: Bind all the ((FIELD VALUE) ...) in a `letrec*'. Adjust `field-value' accordingly. * tests/utils.scm ("define-record-type* with letrec* behavior"): New test.
This commit is contained in:
parent
e4c245f8a5
commit
8fd5bd2b69
2 changed files with 29 additions and 14 deletions
|
@ -112,6 +112,22 @@
|
|||
(match (foo (bar 1))
|
||||
(($ <foo> 1 42) #t)))))
|
||||
|
||||
(test-assert "define-record-type* with letrec* behavior"
|
||||
;; Make sure field initializers can refer to each other as if they were in
|
||||
;; a `letrec*'.
|
||||
(begin
|
||||
(define-record-type* <bar> bar make-bar
|
||||
foo?
|
||||
(x bar-x)
|
||||
(y bar-y (default (+ 40 2)))
|
||||
(z bar-z))
|
||||
(and (match (bar (x 1) (y (+ x 1)) (z (* y 2)))
|
||||
(($ <bar> 1 2 4) #t))
|
||||
(match (bar (x 7) (z (* x 3)))
|
||||
(($ <bar> 7 42 21)))
|
||||
(match (bar (z 21) (x (/ z 3)))
|
||||
(($ <bar> 7 42 21))))))
|
||||
|
||||
(test-end)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue