-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
add import ... as ...
syntax
#37396
add import ... as ...
syntax
#37396
Conversation
Now that's an old issue number! |
Why not import CSV.read as rd
rd(x::Int) = x adds a method to Also, isn't |
Ok, we can allow It might be ok to remove |
Thanks for the consideration. I think I can see the motivation behind
I agree. I guess it has to be written as |
f3e8d03
to
d0a75ca
Compare
Added |
Triage is ok with this. The potential for abuse is very limited, and we think this will most likely only be used on the rare occasion where it's really convenient. The downvoters are free to make their case however :) |
Does it make sense to unsupport |
Two questions about this:
Edit: Hmm... After staring at the second question for another moment, I realized I never actually tried without renaming — I'd just assumed it wouldn't work. But on v1.5.1, I find julia> module FileIO
using FileIO
const a = 1
@show FileIO.a
@show FileIO.load
end
FileIO.a = 1
FileIO.load = FileIO.load
Main.FileIO which I didn't expect. I guess something about name resolution isn't complete/accurate in my mental model. |
It already exists in https://github.com/fredrikekre/ImportMacros.jl (but with the syntax |
Syntactically yes but functionally not as far as I know. With this PR, the identifier |
You underestimate my creativity:
|
d620a28
to
b0e2e53
Compare
I think we should keep this as-is. It's just too surprising for |
There are other "surprising" API in Julia like |
It just seems silly to me. ImportMacros.jl already allows it, so why would we add this syntax but then make you use that package only for one very obvious case of renaming a single identifier? Another possibility might be to disallow method extension for renamed identifiers, instead of disallowing the import syntax. |
I guess it boils down to whether or not Julia wants to be opinionated about code organization. Though I guess Julia has the lispy vibe of allowing almost everything so maybe I'm arguing something nonidiomatic.
Why not
I think the downside is that it might introduce confusion on the difference between |
Triage is ok with this as-is. Note: need to mention |
ebfdcfa
to
b1399e3
Compare
b1399e3
to
e32266c
Compare
Finnaly, I can do |
JuliaLang/julia#37396 added support for this syntax as well, but CSTParser currently returns an error token.
closes #1255