Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-18 Thread Dimaugh Silvestris
Ohhh, thank you so much, Sorawee! Now I have wealth of code to study. By the way, I tried to send my full code but apparently once again I hit the "reply" button instead of "reply all" and I only sent it to David, so here it is again in case anyone wants to play with it. I haven't implemented

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread Sorawee Porncharoenwase
> > 2) (card (line . xs)) has only one field, xs. Of course, you could also > define it as a normal field which contains a list, but there's some other > scenarios where I found it more elegant to represent it as a dotted > argument (like representing s-expressions as a struct). > Oh sorry, that

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread Dimaugh Silvestris
Thanks, I'll take a look into the code struct++! I'll probably get lost but I'm sure I'll learn something. Answering your questions: A) What exactly are you trying to do, because I think I've got it but I'm >>> still fuzzy. >>> >> Structs that allow constructors like any other function, and

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread Dimaugh Silvestris
Oops, noted, I have to use 'reply all'. In the benefit of context I'll post again my reply to Sorawee: Short summary: I'm trying to have a macro (mymacro oldname newname (fields ...)) that accesses oldname-foo, which contains a list of symbols, and then define a function that takes (cons

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread David Storrs
Additional thought and self-plug: My struct-plus-plus module creates structures with full reflection information available, including field names, contracts, and wrappers. It also supports type checking, data normalization, default values, and automatically provides both keyword constructors and

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread David Storrs
NB: You did a 'reply' to Sorawee instead of to the list as a whole, and also the same for the email I sent. Probably good to 'reply all' so that the list gets the full context. Sorawee offered some good advice on how to do the things you're asking about and asked relevant questions. I'm

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread Sorawee Porncharoenwase
Instead of creating hola-fields which exists at run-time, you can (define-syntax hola ...) to a struct containing the field information at compile-time (it probably needs to contain other information too). The struct could have prop:procedure which in this case will be the syntax transformer that

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-16 Thread David Storrs
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

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-16 Thread Sorawee Porncharoenwase
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

[racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-16 Thread Dimaugh Silvestris
(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