fmt icon indicating copy to clipboard operation
fmt copied to clipboard

Simplify define-pretty macro

Open jackfirth opened this issue 1 year ago • 4 comments

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.

jackfirth avatar Aug 13 '24 08:08 jackfirth

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?

sorawee avatar Oct 31 '24 13:10 sorawee

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.

jackfirth avatar Oct 31 '24 19:10 jackfirth

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

sorawee avatar Oct 31 '24 22:10 sorawee

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

jackfirth avatar Oct 31 '24 23:10 jackfirth