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

feat: support #:auto-value for defparam and defthing #391

Merged
merged 1 commit into from
Dec 30, 2023
Merged

Conversation

sorawee
Copy link
Contributor

@sorawee sorawee commented Dec 9, 2023

Manually specifying #:value could be cumbersome. An example is html-empty-tags from the xml collection, which is a list of more than 10 symbols.
It is also error-prone, and could be out-of-sync from the actual value.

This PR adds a support for #:auto-value in defparam and defthing to automatically query the value from the for-label binding.

Thanks to @LiberalArtist for the help in racket/racket#4807.

@sorawee sorawee force-pushed the auto-value branch 2 times, most recently from 6bb2641 to d9c234a Compare December 9, 2023 22:55
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 3 files in this pull request and found no issues.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

@sorawee
Copy link
Contributor Author

sorawee commented Dec 9, 2023

This strategy is not foolproof though. For example, https://github.com/racket/scribble/blob/master/scribble-doc/scribblings/scribble/utils.rkt#L12-L13 bounces the for-label binding, but not the phase 0 binding. So without (require (for-label racket/base)), current-readtable would be identified as originated from utils.rkt, which is not the case. I'm not sure if there's a way to fix the problem. We could also just document the limitation and call it a day...

@sorawee
Copy link
Contributor Author

sorawee commented Dec 10, 2023

Switching from the third result to the first result (nominal-from-mod -> from-mod) seems to help with the above issue.

@sorawee sorawee added this to the 8.12 milestone Dec 10, 2023
github-actions[bot]

This comment was marked as duplicate.

@sorawee sorawee force-pushed the auto-value branch 2 times, most recently from 0cad1b2 to 7d6181d Compare December 10, 2023 13:20
@sorawee
Copy link
Contributor Author

sorawee commented Dec 10, 2023

Addressed feedback by @rocketnia.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

github-actions[bot]

This comment was marked as duplicate.

Copy link
Member

@mflatt mflatt left a comment

Choose a reason for hiding this comment

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

Looks ok to me. Ignore nit-picking comments as you see fit.

scribble-doc/scribblings/scribble/manual.scrbl Outdated Show resolved Hide resolved
scribble-test/tests/scribble/docs/manual-ex.rkt Outdated Show resolved Hide resolved
Manually specifying `#:value` could be cumbersome.
An example is `html-empty-tags` from the `xml` collection,
which is a list of more than 10 symbols.
It is also error-prone, and could be out-of-sync from the actual value.

This PR adds a support for `#:auto-value` in `defparam`
and `defthing` to automatically query the value from
the `for-label` binding.

The original idea of this PR is from
racket/racket#4807.

Thanks to @LiberalArtist who recommended an implementation strategy,
and @rocketnia for feedback.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 3 files in this pull request and found no issues.

@sorawee sorawee merged commit 1944524 into master Dec 30, 2023
3 checks passed
@sorawee sorawee deleted the auto-value branch December 30, 2023 12:41
@sorawee
Copy link
Contributor Author

sorawee commented Dec 30, 2023

Oof, I should have bumped the version and added a history note. Will push a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants