[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Defining defmacro using define-syntax

From: Martin Ward
Subject: Re: [Chicken-users] Defining defmacro using define-syntax
Date: Mon, 13 May 2019 20:38:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

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
         (lambda (e r c)
           (apply (lambda ?args ?body ...) (cdr e))))))))

That works, thanks! :-)


Dr Martin Ward | Email: address@hidden |
G.K.Chesterton site: | Erdos number: 4

reply via email to

[Prev in Thread] Current Thread [Next in Thread]