> On Nov 19, 2016, at 5:33 AM, Dmitry Pavlov <dpav...@iaaras.ru> wrote: > > OK, it seems that I have found the way: > > (define-syntax (call-my-func stx) > (syntax-parse stx > [x:id #'(my-func)] > [(x:id) #'((my-func))] > [(x:id arg ...) #'((my-func) arg ...)]) > ) > > It suits my needs, although is not as simple as would > be a "replace call-my-func with (my-func) disregarding > the circumstances" macro. > Just out of curiosity: is the latter possible?
>From that description, it looks like make-variable-like-transformer is what >you want. The description in the docs says that (make-variable-like-transformer reference-stx) "creates a transformer that replaces references to the macro identifier with reference-stx", and that "uses of the macro in operator position are interpreted as an application with reference-stx as the function and the arguments as given." http://docs.racket-lang.org/syntax/transformer-helpers.html#%28def._%28%28lib._syntax%2Ftransformer..rkt%29._make-variable-like-transformer%29%29 <http://docs.racket-lang.org/syntax/transformer-helpers.html#(def._((lib._syntax/transformer..rkt)._make-variable-like-transformer))> Using that your macro would be: (define-syntax call-my-func (make-variable-like-transformer #'(my-func))) Alex Knauth > Best regards, > > Dmitry > > On 11/19/2016 01:10 PM, Dmitry Pavlov wrote: >> Hello, >> >> I was wondering how I can define a macro that acts without parentheses. >> Here is what I came up with: >> >> (define (my-func) "abc") >> >> (define-syntax (call-my-func stx) >> (syntax-case stx () >> (_ #'(my-func)))) >> >> >> It was fine at the first glance: >> >>> call-my-func >> "abc" >> >> But then I tried >> >>> (call-my-func) >> "abc" >> >> This pose a problem to me in the case when (my-func) returns not >> a constant but a function to be called. >> Besides, it breaks my common sense of Lisp that is >> "an extra pair of parentheses does change things". >> >> Could anybody school me on this topic please? >> >> Best regards, >> >> Dmitry -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.