public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Duncan Mak <duncanmak@gmail.com>,
	kawa mailing list <kawa@sourceware.org>
Subject: Re: How to set procedure name in macros
Date: Mon, 02 Jan 2017 14:17:00 -0000	[thread overview]
Message-ID: <82b7df05-4afd-2723-d8cc-82af0cafa35c@bothner.com> (raw)
In-Reply-To: <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/

      parent reply	other threads:[~2017-01-02 14:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01 23:00 Duncan Mak
2017-01-02  0:37 ` Per Bothner
2017-01-02  2:51   ` Duncan Mak
2017-01-02  2:54     ` Duncan Mak
2017-01-02 14:17 ` Per Bothner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=82b7df05-4afd-2723-d8cc-82af0cafa35c@bothner.com \
    --to=per@bothner.com \
    --cc=duncanmak@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).