-
Notifications
You must be signed in to change notification settings - Fork 19
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
Make Reexport composable with other import macros #30
Conversation
Codecov Report
@@ Coverage Diff @@
## master #30 +/- ##
============================================
+ Coverage 85.71% 100.00% +14.28%
============================================
Files 1 1
Lines 14 20 +6
============================================
+ Hits 12 20 +8
+ Misses 2 0 -2
Continue to review full report at Codecov.
|
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.
Really nice work! Just a couple of comments but overall I like this idea.
303b776
to
fd52f68
Compare
Should I also add some examples to the README? |
I've leave that up to you whether you want to add some examples. Examples are great but I'm also fine accepting this PR as-is. |
Okay cool. Please don't merge this yet. I think I found another edge-case regarding for |
src/Reexport.jl
Outdated
error("@reexport: syntax error") | ||
|
||
if ex.head == :module | ||
modules = Any[ex.args[2]] | ||
ex = Expr(:toplevel, ex, :(using .$(ex.args[2]))) | ||
elseif ex.head == :using && all(e->isa(e, Symbol), ex.args) | ||
elseif ex.head == :using && all(e -> isa(e, Symbol), ex.args) |
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.
@ararslan I think this branch can never be reached? In fact, I removed it and all tests still pass. Do you know more?
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.
Ah, you're right, good catch. This package is very old—it was written for Julia 0.2, I believe—and the way some of these expressions are structured internally has since changed but not all of the code here has been updated to match. (I thought it had been but clearly not!) AFAICT, this branch would have accepted :(using A)
and :(using A.B)
in earlier Julia versions. As you've noticed, it seems now to be dead code.
Another thing that I am wondering: What is the desired behavior of |
I added examples to the README and also handled |
I agree 👍 |
c4a1f66
to
2fa254a
Compare
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.
Great work and thanks for your patience with my review 😄
Thank you for the detailed review! It's my first time meta programming so it's good to get a lot of feedback :) |
This pull-request is an attempt to make Reexport composable with other import macros. This idea originated from Roger-luo/FromFile.jl#25
In order to facilitate compatibility with FromFile.jl (and potentially other import macro tools) this PR introduces the following change:
Base.macroexpand
, thus@reexport
always sees the code as if all the syntax transformations have been written out@reexport
recursively expands all:block
expressions (since macros likeFromFile.@from
return a block of multiple import statements)@reexport import A.b
and@reexport import A: b
which are transformed toimport A.b; export b
andimport A: b; export b
respectively.Please let me know what you think about this proposal. I will add tests, once we've worked out if we want this feature at all. Also, please let me know if you prefer this pull quest to be split up into multiple smaller ones.
Edit:
The feature number 2 above has the nice side-effect that you can now wrap an entire block in a
@reexport
macro: