Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expander: add syntax-local-make-definition-context-introducer #4929

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

usaoc
Copy link
Contributor

@usaoc usaoc commented Feb 7, 2024

Checklist
  • Feature
  • tests included
  • documentation

Description of change

This function makes an introducer that encapsulates a scope that should be pruned from quote-syntax forms, much like an {inside,outside}-edge scope. This can be useful for implementing forms like Rhombus let (which is indeed the motivation; see racket/rhombus#471).

@usaoc
Copy link
Contributor Author

usaoc commented Feb 8, 2024

To clear up potential confusion seeing the mentioning Rhombus issue: this PR does not intend to introduce low-level mechanism for the user to replicate what definition contexts already do. Rather, it’s intended for situation where you want to create scopes that should be pruned for quote-syntax, so it’s limited in scope.

@mflatt
Copy link
Member

mflatt commented Feb 12, 2024

Since the as-inside-edge? argument affects only the debugging name of the scope, would it make sense to generalize that argument to be any symbol that isn't 'macro?

Specifically, I have in mind that this function is useful to add use-site scopes to Rhombus's enforestation-level expansion. The name doesn't matter, but it can help with debugging if things are distinct. Also, seeing a debugging category for Rhombus let by be helpful.

Changing to a symbol would also help clarify that debugging is the only effect of the choice.

@mflatt
Copy link
Member

mflatt commented Feb 12, 2024

As It may also be that syntax-local-apply-transformer is the better way to handle use-site scopes in Rhombus, as @michaelballantyne points out in racket/rhombus#474. But if we're going to expose the more primitive building block directly, then the generalization away from as-inside-edge?.

This function makes an introducer that encapsulates a scope that
should be pruned from `quote-syntax` forms, much like an
{inside,outside}-edge scope.  This can be useful for implementing
forms like Rhombus `let` (which is indeed the motivation; see
racket/rhombus#471).
@usaoc usaoc force-pushed the make-defctxt-intro branch from 871b301 to 590a178 Compare February 13, 2024 17:20
@usaoc
Copy link
Contributor Author

usaoc commented Feb 13, 2024

I incorporated the suggestion and made some clarification to the purpose of this function. I’m not sure how much we still want this change, though.

@mflatt
Copy link
Member

mflatt commented Feb 14, 2024

Thanks for the updates!

Making sure I'm not confused: This is still a useful shortcut for implementing something like let in Rhombus, right? Even with Rhombus using syntax-local-apply-transformer, the scope for each let is separate from the ones managed directly by syntax-local-apply-transformer.

@usaoc
Copy link
Contributor Author

usaoc commented Feb 14, 2024

Yes, if we keep the current implementation strategy for let, that is, managing a single scope for each let.

@mflatt mflatt merged commit 9b057b6 into racket:master Feb 14, 2024
7 checks passed
@usaoc usaoc deleted the make-defctxt-intro branch February 14, 2024 16:19
@shhyou shhyou added the macro system Expander, Syntax Parse, other #lang racket macros label Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macro system Expander, Syntax Parse, other #lang racket macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants