Re: [racket-users] Re: Macro behaves differently when run from different modules

2019-09-28 Thread Ben Greenman
On 9/28/19, Jonathan Simpson wrote: > It works when I change my mag-line syntax class to: > > (define-syntax-class mag-line > (pattern (line expr ...))) > > So removing the literal specifier on line seems to work. I'm still not sure > why the two modules behave differently though. It seemed to

[racket-users] Re: Macro behaves differently when run from different modules

2019-09-28 Thread Jonathan Simpson
It works when I change my mag-line syntax class to: (define-syntax-class mag-line (pattern (line expr ...))) So removing the literal specifier on line seems to work. I'm still not sure why the two modules behave differently though. It seemed to work in expander-utils.rkt whether line was de

[racket-users] Macro behaves differently when run from different modules

2019-09-28 Thread Jonathan Simpson
I've recently been rewriting some ugly code to make it fully hygienic with syntax-parse. I have an implementation that appears to work when testing it from the module that contains the macros, but it fails when I run it from my main program/another module. The macro in question is parse-level0,

Re: [racket-users] Re: embedding a DSL into racket code

2019-09-28 Thread Raoul Schorer
That actually did the trick! Thank you very much for your time :-) Le samedi 28 septembre 2019 17:58:05 UTC+2, Michael Ballantyne a écrit : > > Wherever you parse the string and construct a syntax object, you would use > the original syntax object that contained the string as the ctxt argument >

Re: [racket-users] Re: embedding a DSL into racket code

2019-09-28 Thread Michael Ballantyne
Wherever you parse the string and construct a syntax object, you would use the original syntax object that contained the string as the ctxt argument to datum->syntax for the new syntax object. For example, in your jacket-compiler project you’d change this definition: (define-syntax (j s) #`(int

[racket-users] Re: embedding a DSL into racket code

2019-09-28 Thread Raoul Schorer
> I suspect that your problem relates to the set of scopes that end up on > the binding identifier. > I came to the same conclusion, however I do not understand how I would use `datum->syntax` to copy bindings even after reading on syntax objects, taints, etc. Do you mean using the `ctxt` par

[racket-users] Re: embedding a DSL into racket code

2019-09-28 Thread Michael Ballantyne
Yeah, the `begin` shouldn't be a problem---`define`s splice out of a begin. And it doesn't look like you're missing the binding pass, because you are successfully expanding to module-level `define-values` forms. I suspect that your problem relates to the set of scopes that end up on the binding

[racket-users] Re: embedding a DSL into racket code

2019-09-28 Thread Raoul Schorer
So, I was partly mistaken about what the problem was. My embedding macro seems to work, but the bindings are incorrect. #lang typed/racket (require my-lang-compiler/expander math/array) (define a (array #(3))) (my-lang "a=:4") should raise: 'module: identifier already defined in: a' Bu

[racket-users] embedding a DSL into racket code

2019-09-28 Thread Raoul Schorer
Hi, I have written a #lang, which works ok when it is in its own file. Now, I'd like to make it embedded through a macro such as '(my-lang ...)' What I would like is essentially expand that: #lang racket ... standard racket source ... (my-lang ...) ... standard racket source ... to that: #lang