Re: [racket-users] Re: Is this "inside out" macro technique common?

2021-08-18 Thread Michael Ballantyne
the time, but now I'm less sure. I'll have to > see how it plays out. > On Monday, August 16, 2021 at 12:22:02 PM UTC-5 Michael Ballantyne wrote: > >> The essential primitive here seems to me to be: >> >> (define-syntax (splice stx) >> (syntax-case stx () >>

Re: [racket-users] Re: Is this "inside out" macro technique common?

2021-08-16 Thread Michael Ballantyne
The essential primitive here seems to me to be: (define-syntax (splice stx) (syntax-case stx () [(_ e ...) (eval-syntax #'(begin e ...))])) With with-quasisyntax being: (define-syntax-rule (with-quasisyntax ([a b] ...) template) (splice (with-syntax ([a b] ...) (quasisyntax

[racket-users] Re: The history of hygiene for definition contexts

2021-07-29 Thread Michael Ballantyne
Section 4.5 of Abdulaziz Ghuloum's PhD thesis is the earliest description I've seen of an algorithm: https://www.proquest.com/openview/f6a12fd14db7fd3ea85cfebbf72e0bc5 It also does not provide much justification. The second example you give becomes more natural if you've considered simpler

Re: [racket-users] I made some videos about Racket (a.k.a the return of Playing the Game with PLT Redex)

2021-01-06 Thread Michael Ballantyne
> ... to embed domain specific language in another. Does Racket have any support for this? One approach is discussed in our paper about making macro-extensible DSLs: https://dl.acm.org/doi/abs/10.1145/3428297 Section 8 shows some examples of how extensibility is useful for layering

Re: [racket-users] require and syntax-case

2020-07-14 Thread Michael Ballantyne
> There is another way: syntax-local-introduce will remove the macro scope. `syntax-local-introduce` is no longer useful for this purpose since the switch to the scope sets model. Other scopes, such as module scopes, will often distinguish the macro-introduced name. For example, using

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Michael Ballantyne
/issues/3198) On Sunday, June 7, 2020 at 4:45:34 PM UTC-6, Sorawee Porncharoenwase wrote: > > Wow, so block is currently buggy?! > > On Sun, Jun 7, 2020 at 3:31 PM Michael Ballantyne > wrote: > >> Hah! You're right. The arrow points to the inner definition. But

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Michael Ballantyne
perfectly shows why I need > internal-definition-context-track, however. Thank you very much. > > On Sun, Jun 7, 2020 at 7:51 AM Michael Ballantyne > wrote: > >> > I am unable to come up with a program where this difference is >> significant though >> >>

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Michael Ballantyne
ext-track? Normally, internal definitions are > expanded into letrec-syntaxes+values, so the bindings don’t actually > disappear. So I am curious why internal-definition-context-track is > needed. > > Thanks again. > > On Sat, Jun 6, 2020 at 8:21 AM Michael Ballantyne > wrote: &

[racket-users] Re: identifier used out of context

2020-06-06 Thread Michael Ballantyne
Explicitly expanding `e` would ensure that the expansion work only has to happen once, rather than twice. Even so, the fully-expanded syntax will be expanded again in `syntax-local-bind-syntaxes` and in the expansion. As far as I've seen, the only thing that liberal define contexts control is

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

2019-09-30 Thread Michael Ballantyne
Two identifiers that are both unbound and have the same symbol are considered free-identifier=?. Thus the match works when testing from expander-utils.rkt, where both the pattern and usage are unbound. It also works from expander-utils.rkt when you define `line` in that file, because the

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

2019-09-28 Thread Michael Ballantyne
n e))])) > > In the docs, I however did read about `syntax-binding-set` and > `syntax-binding-set-extend`, that apparently allow manually setting the > bindings of a symbol. Would that be a potential solution? > > > Le samedi 28 septembre 2019 16:05:57 UTC+2, Michael Bal

[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

[racket-users] Re: Splicing the result of one macro into another

2019-08-22 Thread Michael Ballantyne
Here's another implementation you might consider. In this version you can view the body of `phone-numbers` as a language consisting of the `number` and `number-list` syntactic forms. The language also supports its own kind of macros---phone number macros---that can expand to forms of the

[racket-users] Re: how do you read, manipulate, debug scope sets?

2019-05-07 Thread Michael Ballantyne
It's not an answer to your broader question, but I suspect what you actually want here is #+begin_src racket ;; inside syntax-parse (datum->syntax this-syntax '<~) #+end_src Notice that the second argument to datum->syntax should be a symbol here, rather than a syntax object. If you

[racket-users] Re: [racket] Unsafe version of require/typed?

2015-05-01 Thread Michael Ballantyne
I'm delighted to offer both. Here's a particularly pathological test case: https://github.com/michaelballantyne/typed-racket-performance Using a typed/racket/no-check variant of the tr-pfds package makes my untyped code run 1275x faster. The feature-profile tool reports that in the TR variant