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%
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
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
> 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 :
>
> ```
>
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
5 matches
Mail list logo