This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: How to set procedure name in macros
- From: Per Bothner <per at bothner dot com>
- To: Duncan Mak <duncanmak at gmail dot com>, kawa mailing list <kawa at sourceware dot org>
- Date: Sun, 1 Jan 2017 16:37:21 -0800
- Subject: Re: How to set procedure name in macros
- Authentication-results: sourceware.org; auth=none
- References: <CABgWrqrBnhkHXSjj8y6dAK1iVMS42Fnzc0tmWbBckuQkQtbXGA@mail.gmail.com>
On 01/01/2017 02:59 PM, Duncan Mak wrote:
Hello all,
Happy new year!
In my DEFINE-FOO macro and I noticed that I can't control the name of
the lambda in the syntax expansion.
This works:
(define-syntax define-d
(lambda (stx)
(syntax-case stx ()
((_ n) #`(define n (letrec ((foo (lambda () #f)))
(set-procedure-property! foo 'name 'n)
foo))))))
First, you needs to quite the property value.
Secondly, you should not use the same identifier for the syntax parameter
as the name" keyword.
I'm not clear why the following doesn't work - I'm looking into it.
(define-syntax define-c
(lambda (stx)
(syntax-case stx ()
((_ n) #`(define n (letrec ((foo (lambda () name: 'n
#f)))
foo))))))
--
--Per Bothner
per@bothner.com http://per.bothner.com/