Sorawee answered your immediate question, but I figured I'd offer a pointer
to Fear of Macros in case you haven't seen it:
https://www.greghendershott.com/fear-of-macros/  It helped me a lot when I
was trying to get my head around macros.  Also, I got a lot of value from
reading through the code of
https://pkgs.racket-lang.org/package/struct-update

On Thu, Sep 16, 2021 at 4:21 PM Dimaugh Silvestris <
[email protected]> 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 [email protected].
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKod53kD4ZFyxmatP4qx%2BvSKqrnT-if7PCD4MWxA7Tva3-Q%40mail.gmail.com.

Reply via email to