Re: [racket-users] Macro from list to class init

2018-05-15 Thread Matthias Felleisen
What you seen to want is eval not a macro, because the data (including field names) don’t exist at compile time: #lang racket/gui (define-namespace-anchor top) (define frame (new frame% [label "test"])) (define data `((stretchable-width #t) (label "test") (parent ,frame))) (eval `(new button%

Re: [racket-users] Macro from list to class init

2018-05-15 Thread Denis Michiels
Hi, For more explanation about my goal, here is "wrong" version : #lang racket/gui (define frame (new frame% [label "test"])) (send frame show #t) (define-syntax (mk-widget stx) (syntax-case stx () [(_ (list (cons (datum->syntax k) v) ...)) #'(new button% [k v] ...)])) ; Work, but n

Re: [racket-users] Macro from list to class init

2018-05-15 Thread Denis Michiels
Hello, thank you for this start of response, but my goal is to be more general, and not to make specific action (here, the label must be the first in the list, ...). In fact, I want to "rewrite" the `new` function, but only with raw data-type (like list and cons). Or at least, something that tran

Re: [racket-users] Macro from list to class init

2018-05-14 Thread Matthias Felleisen
> On May 14, 2018, at 6:55 AM, Denis Michiels wrote: > > Hello, > > I'm trying to build a macro to be able to do : > > ``` > (define data (list (cons 'label "My button") > (cons 'stretchable-width #t))) > > (my-macro button% data) > ``` > > to be translated in : > > ``` >

[racket-users] Macro from list to class init

2018-05-14 Thread Denis Michiels
Hello, I'm trying to build a macro to be able to do : ``` (define data (list (cons 'label "My button") (cons 'stretchable-width #t))) (my-macro button% data) ``` to be translated in : ``` (new button% [label "My button"] [stretchable-width #t]) ``` (I take gui example, and