mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
* module/language/scheme/translate.scm: Use `(srfi srfi-39)'. (¤t-macros): New top-level. (expand-macro): New. (scheme-primitives): Renamed `%scheme-primitives'. (%forbidden-primitives): New. (trans): Use `expand-macro' instead of `macroexpand'. (trans-pair): Handle `define-macro' and `defmacro'. * module/system/base/compile.scm (call-with-compile-error-catch): Handle non-pair LOC. * testsuite/t-macros2.scm: New test case. * testsuite/Makefile.am (vm_test_files): Updated. * testsuite/t-macros.scm: Test `read-options'. git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-9
17 lines
359 B
Scheme
17 lines
359 B
Scheme
;; Are macros well-expanded at compilation-time?
|
||
|
||
(defmacro minus-binary (a b)
|
||
`(- ,a ,b))
|
||
|
||
(define-macro (plus . args)
|
||
`(let ((res (+ ,@args)))
|
||
;;(format #t "plus -> ~a~%" res)
|
||
res))
|
||
|
||
|
||
(plus (let* ((x (minus-binary 12 7)) ;; 5
|
||
(y (minus-binary x 1))) ;; 4
|
||
(plus x y 5)) ;; 14
|
||
12 ;; 26
|
||
(expt 2 3)) ;; => 34
|
||
|