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

macros: add stamp for unquoting a template body #1426

Merged
merged 3 commits into from
Aug 21, 2024

Conversation

alaviss
Copy link
Contributor

@alaviss alaviss commented Aug 21, 2024

Summary

Add stamp to std/macros , which takes a template body and applies
it immediately. This is the same behaviour as the previous quote
that was changed after #1393.

Details

After #1393 we have a hole in
the stdlib for quote -like interpolation but with automatic binding
of symbols to reduce boilerplate. Various libraries within the ecosystem
such as criterion and npeg have found the feature useful and
extensively employ it.

Reintroduces old quote behavior as stamp , without support for
custom operators and explicitly document the template-like nature of
stamp 's body as well as its pitfalls.

This macro was originally written and shared to Matrix by @zerbina.

@alaviss alaviss added enhancement New feature or request stdlib Standard library labels Aug 21, 2024
Copy link
Collaborator

@saem saem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor correction in the doc block to make it explicit what the behaviour of stamp is, also I'll update the PR body a bit, just lead with the introduction of the new macro and its behaviour.

lib/core/macros.nim Outdated Show resolved Hide resolved
Copy link
Collaborator

@zerbina zerbina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the elaborate documentation and examples! I'm not super happy of having this behaviour be in the standard library, but at least it's properly documented now, with all it's quirks.

There's one problem with the documentation that needs fixing, and some few other things that should be changed, but this looks good to me otherwise.

lib/core/macros.nim Outdated Show resolved Hide resolved
lib/core/macros.nim Outdated Show resolved Hide resolved
lib/core/macros.nim Outdated Show resolved Hide resolved
@saem
Copy link
Collaborator

saem commented Aug 21, 2024

Updated the PR body so it leads with the change.

@alaviss alaviss requested a review from zerbina August 21, 2024 18:23
@zerbina
Copy link
Collaborator

zerbina commented Aug 21, 2024

/merge

Copy link

Merge requested by: @zerbina

Contents after the first section break of the PR description has been removed and preserved below:


Notes for Reviewers

  • Unlike the version shared on Matrix, this version excludes result from being bound automatically.

@chore-runner chore-runner bot added this pull request to the merge queue Aug 21, 2024
Merged via the queue into nim-works:devel with commit 89b45fc Aug 21, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stdlib Standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants