Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Jonathan Simpson
Yes, this did the trick! I needed to add datum->syntax to the identifiers in BOTH macros. In my initial attempt I only added it to the defining macro. More importantly, I now understand why I needed to do it this way. I plan to eventually refactor it to pass the identifier in directly instead of

Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Matthew Butterick
> On May 28, 2019, at 7:11 AM, Jonathan Simpson wrote: > > Both the function definition and function calls are created by similar > looking macros which pass strings as the function name. I've now taken steps > to break hygiene in the defining macro, but the calling macro just converts > the

Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Jonathan Simpson
On Tuesday, May 28, 2019 at 1:45:35 AM UTC-4, Alexis King wrote: > > > On May 27, 2019, at 22:28, Jonathan Simpson > wrote: > > > > I may be missing something, but I didn't think I could use the name as > valid syntax since this is the form that is creating it. If passing a > symbol in would

Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Jonathan Simpson
Sorry. It is probably better to ignore the part about the second syntax-case clause for now. I didn't provide the necessary background to make sense of it. Once I get past my current problem it probably won't be relevant anyway. I'm currently hitting the unbound identifier error in both clauses

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Sorawee Porncharoenwase
On Mon, May 27, 2019 at 7:54 PM Greg Hendershott wrote: > p.s. That (datum->syntax _ (string->symbol (syntax->datum _))) triplet > has an equivalent handy shortcut -- `format-id`: > > (format-id #'magic-name "~a" #'magic-name) This doesn't work in the string literal case because an argument

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Alexis King
> On May 27, 2019, at 22:28, Jonathan Simpson wrote: > > I may be missing something, but I didn't think I could use the name as valid > syntax since this is the form that is creating it. If passing a symbol in > would work then I could potentially change my lexer to do that instead of a > stri

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Greg Hendershott
It seemed like most of your question was about creating the name identifier for the `define`. I focused on (and hopefully answered) that part. But I didn't pick up on what you said the error message was: >> attempts to use with-syntax* also fail with errors like "modified-rst: >> unbound identifie

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Jonathan Simpson
In case this helps, here is the output from the macro stepper for a sample macro invocation: (named-query (name-line (offset 0) (name-type "name") "always-true") (level) (line (offset 0) (type (default "default")) (test (truetest "x" -> (define:24 always-true

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Jonathan Simpson
Thanks for the quick response. I wouldn't have gotten as far as I have so far without your 'Fear of Macros' page, so thanks for that as well! On Monday, May 27, 2019 at 10:54:50 PM UTC-4, Greg Hendershott wrote: > > If users of your `named-query` macro will supply the name as an > identifier --

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Greg Hendershott
If users of your `named-query` macro will supply the name as an identifier -- an unquoted symbol like some-name in this example: (named-query (name-line (_ 0) (_ "name") some-name)) Then what your macro needs to do with the pattern variable is... just use it -- as is -- in the template. (It is