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