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]

How to set procedure name in macros


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!


-- 
Duncan.


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