[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:15:30 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
On 13/05/19 19:28, Phil Bewig wrote:
From the Standard Prelude <http://programmingpraxis.com/standard-prelude> at my
blog <http://programmingpraxis.com>:
(define-syntax (define-macro x)
(syntax-case x ()
((_ (name . args) . body)
(syntax (define-macro name (lambda args . body))))
((_ name transformer)
(syntax
(define-syntax (name y)
(syntax-case y ()
((_ . args)
(datum->syntax-object
(syntax _)
(apply transformer
(syntax-object->datum (syntax args)))))))))))
This gives the following error:
% csi
CHICKEN
(c) 2008-2018, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.0.0 (rev 12f2f2cc)
linux-unix-gnu-x86-64 [ 64bit dload ptables ]
#;1> (define-syntax (define-macro x)
(syntax-case x ()
((_ (name . args) . body)
(syntax (define-macro name (lambda args . body))))
((_ name transformer)
(syntax
(define-syntax (name y)
(syntax-case y ()
((_ . args)
(datum->syntax-object
(syntax _)
(apply transformer
(syntax-object->datum (syntax args)))))))))))
Error: during expansion of (define-syntax ...) - in `define-syntax' -
symbol expected: (define-syntax (define-macro x) (syntax-case x () ((_
(name . args) . body) (syntax (define-macro name (lambda args . body))))
((_ name transformer) (syntax (define-syntax (name y) (syntax-case y ()
((_ . args) (datum->syntax-object (syntax _) (apply transformer
(syntax-object->datum (syntax args)))))))))))
Call history:
<syntax> (define-syntax (define-macro x) (syntax-case
x () ((_ (name . args) . body) (syntax (define-macro na... <--
#;1>
--
Martin
Dr Martin Ward | Email: address@hidden | http://www.gkc.org.uk
G.K.Chesterton site: http://www.gkc.org.uk/gkc | Erdos number: 4