[Top][All Lists]

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

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

From: Phil Bewig
Subject: Re: [Chicken-users] Defining defmacro using define-syntax
Date: Mon, 13 May 2019 13:28:38 -0500

From the Standard Prelude at my blog:

(define-syntax (define-macro x)

  (syntax-case x ()
    ((_ (name . args) . body)
      (syntax (define-macro name (lambda args . body))))
    ((_ name transformer)
       (define-syntax (name y)
         (syntax-case y ()
           ((_ . args)
               (syntax _)
               (apply transformer
                 (syntax-object->datum (syntax args)))))))))))  

On Mon, May 13, 2019 at 1:24 PM Martin Ward <address@hidden> wrote:

The FermaT program transformation system is implemented in WSL
and translated to Scheme for compiling or interpreting.

It was originally developed using SCM scheme which uses defmacro
to define macros, eg:

(defmacro floop (name . body)
      (lambda (,name)
        (do () (#f #t)

(defmacro pop (v1 v2)
      (set! ,v1 (car ,v2))
      (set! ,v2 (cdr ,v2))))

(defmacro push (v e)
   `(set! ,v (cons ,e ,v)))

I am trying to port it to other Scheme versions. For bigloo
I can use define-macro to define defmacro as a macro:

(define-macro (defmacro name . forms)
   \`(define-macro (,name . ,(car forms)) ,\@(cdr forms)))

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?


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

Chicken-users mailing list

reply via email to

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