-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Generate Temporay Identifiers On-the-fly #22
Comments
That's nice! Is there a particular reason why |
Some macros may |
bennn
added a commit
to syntax-objects/syntax-parse-example
that referenced
this issue
Sep 21, 2021
bennn
added a commit
to syntax-objects/syntax-parse-example
that referenced
this issue
Oct 27, 2021
bennn
added a commit
to syntax-objects/syntax-parse-example
that referenced
this issue
Oct 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Macro
Some macros need to generate a sequence of fresh identifiers corresponding to a list of input forms. The standard solution is invoking
generate-temporaries
with a syntax list and bind the result to a new pattern variable. However, the new pattern variable is disconnected from the input forms and such an approach quickly becomes unmanageable when the input forms come nested in more than one ellipses.By delegating the work to syntax classes, the syntax attributes tightly couples the generate identifiers with the input forms (and they even have DrRacket binding arrows). Moreover, repetition handling is entirely done by syntax/parse, thereby simplifying the code.
Example
In this example, we create a
define/immutable-parameter
form for defining function while disabling mutation of the parameters throughmake-variable-like-transformer
.The macro
define/immutable-parameter
parses the argumentsarg
withfresh-variable
to generate temporary identifiers on-the-fly. Each of the fresh identifier is directly paired with the original identifier through syntax attributes.Licence
I license the code in this issue under the same MIT License that the Racket language uses and the texts under the Creative Commons Attribution 4.0 International License
The text was updated successfully, but these errors were encountered: