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
[RecipesBase] Use interpolation instead of qualification to drop dependance on the namespace of RecipesBase users #4559
Conversation
CI is already failing after just a few minutes <3 |
Use interpolation instead of qualification
We can't expect them to have all those internal functions in the namespace either, I'd say. using RecipesBase: RecipesBase, @recipe |
As Simon suggested, improving the docs is probably the easiest. With a minor nitpick: import RecipesBase: RecipesBase, @recipe |
The original approach (fb77991) should work if JuliaLang/julia#47726 is fixed upstream. |
Failing that, a slightly more verbose approach should work following this pattern julia> module NanoRecipesBase
function apply_recipe end
macro recipe(x)
quote
let M = $NanoRecipesBase
M.apply_recipe() = $x
end
end
end
end
Main.NanoRecipesBase
julia> module User
import Main.NanoRecipesBase: @recipe
try
println(NanoRecipesBase)
catch UndefVarError
println("Good")
end
@recipe 1729
end
Good
Main.User
julia> NanoRecipesBase.apply_recipe()
1729 |
ea2fd25
to
2a131a3
Compare
We should only document an unexpected limitation/bug if we can't fix it. This PR should fix it :) |
Codecov ReportBase: 90.94% // Head: 90.95% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #4559 +/- ##
=======================================
Coverage 90.94% 90.95%
=======================================
Files 40 40
Lines 7800 7802 +2
=======================================
+ Hits 7094 7096 +2
Misses 706 706
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The format check gave a lot of diffs. Is there a way to avoid transcribing all those non-functional-changes manually? |
https://docs.juliaplots.org/latest/contributing/#Write-code,-and-format $ julia -e 'using JuliaFormatter; format(["src", "test"])' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
Seems like using |
Strange. I guess I'll just revert to 5440348 "fix formatting". |
abab70a
to
5440348
Compare
I don't understand the |
5440348
to
de5a423
Compare
Thanks @ffevotte from discourse for the latest and best workaround for julia#47726 |
Looks good, thanks for getting to the bottom of this with a cleaner solution. Still intrigued by the |
No. There should not be a runtime penalty. |
Ultimately, it's just a style/formatting choice. I prefer direct interpolation over module interpolation + qualified reference because it is shorter, but either should work, and y'all are more likely to be maintaining this than me so feel free to pick whatever style you prefer. |
We disagree on this one, and I explained my position in #4559 (comment). Thanks for the contribution and the detailed analysis here, always useful to learn about the internals ! |
We can't assume that folks will have RecipesBase in their namespace.
Fixes #4557