guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with macro


From: Mike Gran
Subject: Re: Need help with macro
Date: Thu, 13 Dec 2018 10:14:04 -0800
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Dec 12, 2018 at 08:34:13PM -0500, Mark H Weaver wrote:
> Here's a syntax-rules macro to do it:
> 
>   (define-syntax send
>     (syntax-rules ()
>       ((send self (method arg ...))
>        (call-method self (symbol->string 'method) `(,arg ...)))))
> 
> However, in this implementation, the 'symbol->string' call is deferred
> to run time.
> 
> Here's a syntax-case macro that does the conversion at compile time:
> 
>   (define-syntax send
>     (lambda (stx)
>       (syntax-case stx ()
>         ((send self (method arg ...))
>          (identifier? #'method)
>          (with-syntax ((method-str (symbol->string
>                                     (syntax->datum #'method))))
>            #'(call-method self method-str `(,arg ...)))))))

Great!  This is what I needed.  Thanks for help.

-Mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]