Re: [racket-users] Cleanest way to 'if/then' inside a macro?

2019-05-15 Thread David Storrs
On Wed, May 15, 2019 at 12:59 PM Stephen Chang wrote: > > For the same reasons I would use a `let` around a code block -- it's an > easy way to isolate computation and create reusable elements. What would a > more normal way be when using syntax-parse? > > The #:with syntax-parse "pattern

Re: [racket-users] Cleanest way to 'if/then' inside a macro?

2019-05-15 Thread Stephen Chang
> For the same reasons I would use a `let` around a code block -- it's an easy > way to isolate computation and create reusable elements. What would a more > normal way be when using syntax-parse? The #:with syntax-parse "pattern directive" does the same thing, but with less parens.

Re: [racket-users] Cleanest way to 'if/then' inside a macro?

2019-05-15 Thread David Storrs
On Wed, May 15, 2019 at 11:48 AM Stephen Chang wrote: > answer 1) You are missing a dot in (~@ propthing), ie this will work: > (~@ . propthing) > Ah, nice I missed that in the docs. Thanks, Stephen. > minor question) is there a reason you are using with-syntax with > syntax-parse? > For

Re: [racket-users] Cleanest way to 'if/then' inside a macro?

2019-05-15 Thread Stephen Chang
answer 1) You are missing a dot in (~@ propthing), ie this will work: (~@ . propthing) minor question) is there a reason you are using with-syntax with syntax-parse? answer 2) You may want to try "attribute". It's somewhat like "syntax", except it returns false when there are unbound patvars,

[racket-users] Cleanest way to 'if/then' inside a macro?

2019-05-15 Thread David Storrs
I'd like to find a general mechanism, when writing macro code, to say "If this optional argument was supplied, generate this code. If not, generate this other code", where "this other code" might be nothing at all. I feel like this should be simple, but my brain is failing. As an example,