Re: [racket-users] macro making a struct with a macro

2015-08-18 Thread Greg Hendershott
Although maybe off-topic regarding macrology: You might want to consider factoring out the generally useful part, which I think is the less-verbose accessors. An already less verbose way is to use match-define or match-let, for example: (struct s (a b c)) (define x (s 1 2 3)) (match-define (s a

Re: [racket-users] macro making a struct with a macro

2015-08-17 Thread Deren Dohoda
Very helpful, thank you. You're right that the #:methods spec was messing up the original macro, too. Though it had some other problems after I got beyond that hurdle. Every time I think I am starting to understand macros I find out I don't. Deren On Tue, Aug 18, 2015 at 12:43 AM, Alexander D. K

Re: [racket-users] macro making a struct with a macro

2015-08-17 Thread Alexander D. Knauth
I'm not sure why that doesn't work, but I redid it with my define-struct-fields macro factored out and this worked: I'm not sure but I suspect the real difference comes from passing gen:printable to the pstruct macro though, because that's what causes this to fail. I also had to add the optional

Re: [racket-users] macro making a struct with a macro

2015-08-17 Thread Deren Dohoda
Thanks for your help Alexander. I did have this much working alright in a different manner. What I guess I wanted was that this syntax was introduced per struct so that the same syntax worked for all interface-structs. That is, if I (interface-struct test (a b c) [(define (some-interface-function

Re: [racket-users] macro making a struct with a macro

2015-08-17 Thread Alexander D. Knauth
Are you looking for a macro like this: #lang racket (require syntax/parse/define (for-syntax racket/syntax)) (define-simple-macro (define-struct-fields struct:id (field:id ...) v:expr) #:with s (generate-temporary #'struct) #:with [struct-field ...] (for/list ([field (in-list (syntax->list #'