mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
* testsuite/t-match.scm: * testsuite/t-records.scm: While the attempt to redefine use-syntax as being "use during compilation" was cute, it does not reflect the historical usage of use-syntax, nor does it correspond to existing code that includes other modules and uses them during compilation. So use-syntax has been replaced with use-modules. The test suites now pass. In the future, compilation phases should be done on whole modules, I think; r5rs-style computation does not have phases.
26 lines
561 B
Scheme
26 lines
561 B
Scheme
;;; Pattern matching with `(ice-9 match)'.
|
||
;;;
|
||
|
||
(use-modules (ice-9 match)
|
||
(srfi srfi-9)) ;; record type (FIXME: See `t-records.scm')
|
||
|
||
(define-record-type <stuff>
|
||
(%make-stuff chbouib)
|
||
stuff?
|
||
(chbouib stuff:chbouib stuff:set-chbouib!))
|
||
|
||
(define (matches? obj)
|
||
; (format #t "matches? ~a~%" obj)
|
||
(match obj
|
||
(($ stuff) => #t)
|
||
; (blurps #t)
|
||
("hello" #t)
|
||
(else #f)))
|
||
|
||
|
||
;(format #t "go!~%")
|
||
(and (matches? (%make-stuff 12))
|
||
(matches? (%make-stuff 7))
|
||
(matches? "hello")
|
||
; (matches? 'blurps)
|
||
(not (matches? 66)))
|