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

Simplify define-pretty macro #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jackfirth
Copy link
Contributor

This pull request changes the pretty syntax parameter to an ordinary function that calls whatever function is in current-pretty. This removes the need for the #:default keyword in define-pretty, and as a result the #:let keyword isn't needed anymore either. This makes define-pretty macro uses a bit more readable since they can now use ordinary default function arguments and local definitions.

This commit changes the `pretty` syntax parameter to an ordinary function that calls whatever function is in `current-pretty`. This removes the need for the `#:default` keyword in `define-pretty`, and as a result the `#:let` keyword isn't needed anymore either. This makes `define-pretty` macro uses a bit more readable, since they can now use ordinary default function arguments and ordinary local definitions.
@sorawee
Copy link
Owner

sorawee commented Oct 31, 2024

Oh, I think I did it that way to break the cycle, because pretty is actually not a function, but rather a shorthand for (unbox (current-pretty))?

https://github.com/sorawee/fmt/blob/master/core.rkt#L136

The fact that your PR passes the CI is puzzling to me though. Maybe things work and there's no need to break the cycle after all?

@jackfirth
Copy link
Contributor Author

Yeah the cycle is fine. Indirection through the box is enough to break it. Though I am surprised it uses a box at all instead of a parameter.

@sorawee
Copy link
Owner

sorawee commented Oct 31, 2024

I recall I benchmarked at some point and found box to be significantly faster? Not sure though.

@jackfirth
Copy link
Contributor Author

Ah, that makes sense. Parameters have the overhead of thread cells to worry about.

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