Re: [racket-users] Macro calling macro

2016-11-11 Thread Matthew Butterick
On Nov 11, 2016, at 10:16 AM, dear chap wrote: > Hi MB > That did the trick. Using the macro stepper didnt help much but after > running the (message-syntax ...) I see the message object getting populated > correctly with field objects. Why is there a difference ? `quote` converts its input

Re: [racket-users] Macro calling macro

2016-11-11 Thread dear chap
Hi MB That did the trick. Using the macro stepper didnt help much but after running the (message-syntax ...) I see the message object getting populated correctly with field objects. Why is there a difference ? Thanks p.s pollen is the reason I started learning Racket. Thanks !!!. On Frida

Re: [racket-users] Macro calling macro

2016-11-11 Thread Matthew Butterick
On Nov 11, 2016, at 7:24 AM, dear chap wrote: > (define-syntax (message-syntax stx) > (syntax-parse stx > ([_ name field:field_binding ...] > #`(begin >(define message-inst (message 'name '((field-syntax field) ...) > > > I want the message object to contain the nam

[racket-users] Macro calling macro

2016-11-11 Thread dear chap
Hi I'm writing a macro similar to this (struct field (x y z) ) (struct message (name field-list)) (define-syntax (field-syntax stx) (syntax-parse stx ([_ field:field_binding] #`(begin (field 1 2 5) (define-syntax (message-syntax stx) (syntax-parse stx ([_ na

Re: [racket-users] Macro calling macro question

2016-05-20 Thread Kevin Forchione
Both techniques worked for me! Thanks! I’m not sure why (format-id #’n “foo~a” [syntax-e #’n)) works when (format-id six “foo~a” (syntax-e #’n)) does not though. Apparently I need to look into the differences between the two contexts. -Kevin > On May 20, 2016, at 2:58 PM, Sam Caldwell wrote:

Re: [racket-users] Macro calling macro question

2016-05-20 Thread Sam Caldwell
Kevin, I have made this exact mistake in the past. The trouble is with the lexical context being passed to `format-id`. (_foo 3) foo3 ;; 3 Here, _foo is passed the syntax #'(_foo 3), which came from the same environment as the reference, foo3. (foo 3) foo3 ;; error ... Here, _foo is passed the

Re: [racket-users] Macro calling macro question

2016-05-20 Thread Jens Axel Søgaard
The macro application (foo 3) expands into #'(begin (_foo n0) (foo n ...)) The expansion of (_foo n0) then defines foo3, but the scope will only include the piece of code above. To make definitions made by sub-macros available at

[racket-users] Macro calling macro question

2016-05-20 Thread Kevin Forchione
Hi guys, I’ve been interested in having a macro build a series of defines. So I decided to start small, trying to get to a macro that would do something like the following to begin with: >(foo 3) (define foo1 1) (define foo2 2) (define foo3 3) I start with a macro that appears to do a single de