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: Mon, 2 Jan 2017 06:16:27 -0800
- Subject: Re: How to set procedure name in macros
- Authentication-results: sourceware.org; auth=none
- References: <CABgWrqrBnhkHXSjj8y6dAK1iVMS42Fnzc0tmWbBckuQkQtbXGA@mail.gmail.com>
I checked in a fix for the following.
I also checked in a testcase based on yours in testsuite/reflect-fname.scm. Thanks!
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.
Here's a test case -
(define-syntax define-a
(lambda (stx)
(syntax-case stx ()
((_ name) #`(define name (lambda () #f))))))
(define-syntax define-bar
(lambda (stx)
(syntax-case stx ()
((_ name) #`(define name (lambda () name: 'bar #f))))))
(define-syntax define-c
(lambda (stx)
(syntax-case stx ()
((_ name) #`(define name (letrec ((foo (lambda () name: name
#f))) foo))))))
(define-syntax define-d
(lambda (stx)
(syntax-case stx ()
((_ name) #`(define name (letrec ((foo (lambda () #f)))
(set-procedure-property! foo 'name name) foo))))))
(define-a a)
(format #t "Should say a: ~A~%" (procedure-property a 'name))
(define-bar b)
(format #t "Should say bar: ~A~%" (procedure-property b 'name))
(define-c c)
(format #t "Should say c: ~A~%" (procedure-property c 'name))
(define-d d)
(format #t "Should say d: ~A~%" (procedure-property d 'name))
The output looks like this:
Should say a: a
Should say bar: b
Should say c: foo
Should say d: foo
I'm particularly interested in the C or D cases.
Thanks!
--
--Per Bothner
per@bothner.com http://per.bothner.com/