;; CHICKEN
;; (c) 2008-2021, The CHICKEN Team
;; (c) 2000-2007, Felix L. Winkelmann
;; Version 5.3.0 (rev e31bbee5)
;; linux-unix-gnu-x86-64 [ 64bit dload ptables ]

(import (chicken pretty-print))
(import procedural-macros)

;; a simple un-hygienic macro that sets p to a lambda expression
;; using define-er-macro - errors out on lambda no args
;;
;; a lambda one arg is fine ...

(define-er-macro (foo-1)
  %
  `(,%set! p (,%lambda () 32)))
;; foo-1 definition rejected
;; => Error: (define-er-macro) "during expansion of (define-key-macro1672
...) - no nil in car position": ()

;; however a lambda with one argument is accepted
(define-er-macro (foo-2)
  %
  `(,%set! p (,%lambda (z) (+ z 32))))

;; and we can see the expanded code
(pp (expand '(foo-2)))
;; => (##core#set! p (lambda1575 (z) (+ z 32)))

Reply via email to