In general, it would be helpful to provide an example of the macro use, so that we know what you want to do. If it doesn't work, it would be helpful to provide the buggy program and an error message so that we can help with the issue that you are encountering.
>From my guess, you have a variable named abc-foo somewhere, and with this macro, you wish to define a function named abc that can access the value of abc-foo? If so, here’s an example of a working program: #lang racket (require (for-syntax racket/syntax)) (define-syntax (my-macro stx) (syntax-case stx () [(_ name other-args ...) (with-syntax ([varname (format-id #'name "~a-foo" #'name)]) #'(define name (λ (other-args ...) (println (list varname other-args ...)))))])) (define abc-foo 123) (my-macro abc x y) (abc 5 6) ;=> '(123 5 6) On Thu, Sep 16, 2021 at 1:21 PM Dimaugh Silvestris < dimaughsilvest...@gmail.com> wrote: > (sorry if I'm asking too many questions about macros lately, I'm learning > about them but I keep running into scenarios I can't find documentation for) > > I'm trying to capture the value of a variable whose identifier I can only > get with format-id, inside a with-syntax. > Something like this pseudocode (imagine name-foo contains a list of > symbols): > (define-syntax (my-macro stx) > (syntax-case stx () > ((_ name other-args ...) > (with-syntax* ((varname (format-id #'name "~a-foo" #'name)) > (varval (cons (datum->syntax #'varname) (datum->syntax > #'(other-args ...))))) > #'(define name (λ varval (print varval))))))) > > > Which of course doesn't work. I understand this might have to do with how > macros work at an earlier phase than runtime, so is it impossible? > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CAN4YmRF%3Do3NsXOvK2fvUDeYL_jfA9r946%3D%3DguoGb_%3DKyS%3Dm%2Bxw%40mail.gmail.com > <https://groups.google.com/d/msgid/racket-users/CAN4YmRF%3Do3NsXOvK2fvUDeYL_jfA9r946%3D%3DguoGb_%3DKyS%3Dm%2Bxw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CADcueguMfdx5zjRw4iP%3D3_7PhzjpzSMbS02pzVqTPwGMfP7jjQ%40mail.gmail.com.