On 13/05/19 19:35, Peter Bex wrote:
On Mon, May 13, 2019 at 07:11:40PM +0100, Martin Ward wrote:
Chicken scheme does not appear to have defmacro or define-macro
but does have define-syntax.

Is there a way to define defmacro using define-syntax?

This is of course highly discouraged (because defmacro is
inherently unhygienic), but you can do:

(import (chicken syntax))

(define-syntax defmacro
  (syntax-rules ()
    ((_ ?name ?args ?body ...)
     (define-syntax ?name
       (er-macro-transformer
         (lambda (e r c)
           (apply (lambda ?args ?body ...) (cdr e))))))))

That works, thanks! :-)

--
                        Martin

Dr Martin Ward | Email: [email protected] | http://www.gkc.org.uk
G.K.Chesterton site: http://www.gkc.org.uk/gkc | Erdos number: 4

_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to