This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to set procedure name in macros




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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]