-
Notifications
You must be signed in to change notification settings - Fork 11
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
Avoid type piracy? #21
Comments
(all your notes are helpful) The flexibility and internal functions accompanying Specializing In that light, consider the |
Is there any other way to use |
If you need some If you think extending/implementing |
I agree. Time to disentangle. |
I appreciate that you are open-minded about this. |
The next version removes most of it (the
I had done the same with |
In the new version (next release), I am eliminating (release notice and deprecation with a warning for a short while) the use of |
What would you think of also removing the piracy on type values? Here's how it bit me: I was using NamedTupleTools in my project for the I guess the pirate functionality is very useful to some, but for me it's a turn off as I don't want to learn false ideas of what's in Base... |
I agree with quashing piracy --and I did not intend that (or maybe Julia evolved over my initial setup).That you encountered difficulty saddens me. The conflict must be removed. |
Great to hear (and thanks for this package, I'm grateful to have it and this small issue doesn't change that!) |
By existing methods do you mean methods defined in Base?
|
Yes I mean methods defined in Base. Note that the "problem" I encountered is not a conflict, but rather the surprise that things that look like basic Julia code actually only work when NamedTupleTools is loaded. For example, in bare Julia the following doesn't work: julia> NamedTuple{(:a, :b)}(1, 2)
ERROR: MethodError: no method matching (NamedTuple{(:a, :b)})(::Int64, ::Int64) But in my project it was working because I had NamedTupleTools loaded: julia> using NamedTupleTools
julia> NamedTuple{(:a, :b)}(1, 2)
(a = 1, b = 2) Later, I did the same thing in a test file without NamedTupleTools and was surprised to have an error. So to answer your points: I encountered piracy with the function called NamedTuple{T}(xs...) where {T} = NamedTuple{T}(xs) |
Hmm. This is not piracy. There is no misappropriation from Base nor is any valid evaluation logic altered. The definition does introduce a different valid output from some given input. This was introduced into NamedTupleTools to bridge an omission; the facility has developed a healthy following. I will revisit this from the perspective of Base (NamedTuples.jl) using a PR. Stay tuned. Your comments are welcome (I will post the link when ready). |
I guess it depends how you define it... As I understand type piracy applies whenever a method you don't own is extended with a signature of types you don't own. In this sense, the case here is indeed piracy: NamedTupleTools defines I agree that the new constructor defined by NamedTupleTools is unlikely to cause troubles, but just for the sake of the argument, imagine that a future version of Julia defines NamedTuple{(:a, :b)}(i::Int64, j::Int64) = Array{NamedTuple{(:a, :b)}}(undef, i, j) Yes this would be silly, but the point is that Base owns
You mean a PR to put this functionality in Base itself? That would be awesome :-) |
It would be nice if you can avoid type piracy of these functions:
NamedTupleTools.jl/src/NamedTupleTools.jl
Line 22 in f36eff5
The text was updated successfully, but these errors were encountered: