mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-18 18:40:22 +02:00
* module/language/scheme/translate.scm (¤t-macros): Removed. (¤t-macro-module): Removed. (&compile-time-module): New. (eval-at-compile-time): New. (translate): Initialize `&compile-time-module'. (expand-macro)[use-syntax]: New case. [begin let...]: Don't expand these built-in macros. [else]: Rewrote the macro detection and invocation logic. Invoke macro transformers in the current compile-time module. (trans): Let `expand-macro' raise an exception if needed. (trans-pair)[defmacro define-macro]: Evaluate the macro definition in the compile-time module. * testsuite/t-match.scm: Use `use-syntax' instead of `use-modules' for `(ice-9 match)' and `(srfi srfi-9)'. * testsuite/t-records.scm: Likewise. git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-15
27 lines
627 B
Scheme
27 lines
627 B
Scheme
;;; Pattern matching with `(ice-9 match)'.
|
||
;;;
|
||
|
||
;; Both modules are compile-time dependencies, hence `use-syntax'.
|
||
(use-syntax (ice-9 match))
|
||
(use-syntax (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)))
|