mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
* testsuite/t-match.scm (matches?): Fix match invocation. As far as I can tell, although (ice-9 match) does advertise a => form of clauses, it requires that the end of the => be a symbol. For some reason this works in the interpreter: ((lambda () (begin => #t))) It's part of the expansion of matches?. It also worked in the old compiler. Thinking that maybe toplevel references could cause side effects, I made the new compiler actually ref =>, which brought this to light.
26 lines
558 B
Scheme
26 lines
558 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)))
|