-
Notifications
You must be signed in to change notification settings - Fork 67
remove vcat(A::Vector{<: MatrixElem}) #409
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
Conversation
This is commiting "type-piracy". This method is already defined in Base and gives a different result, i.e. vcat on a Vector returns another Vector equal to the input. Similar for hcat.
MatrixElem is not defined in Base. Why is this type piracy? |
Ok, this is type piracy for a loose definition of "type piracy" (defining |
The benefit is that I don't have to splat the arguments when I want to concatenate a vector of matrices. Also splatting is hard on the compiler and pretty much non-discoverable for a user. |
Or what if I have an iterator |
I think the performance of this will be sensibly equal to that of a literal
I argue that the
This example actually supports my point. The existing |
As you noticed yourself, it is not only convenience, but also a matter of speed. Splatting is not for free. Base is only running into trouble and ambiguities since they want to treat numbers as arrays/collections. We don't do this for ring elements so there are no corner cases. The julia concatenation functions are already full of corner cases: julia> [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> A = [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> [A A; A A] # Why not Arry{Array{Int64, 2}, 2} or Array{Int64, 4}?
4×4 Array{Int64,2}:
1 2 1 2
3 4 3 4
1 2 1 2
3 4 3 4 |
I agree with @thofma . This is definitely not type piracy. We have checked carefully with the Julia people that it is only type piracy if it overloads a Base function for a Base type. Otherwise, how would we define exp of a power series for example? The function exp is a Base function, but one has to overload it for one's own types. I also agree that in some cases the Julia conventions are not workable for us. So I have no problem with doing something different. |
I agree that it can be a matter of speed, but it doesn't have to be the same name. If splatting becomes necessary with AFAICT (I may very well be wrong), with the "nice" syntax (i.e. literal I have nothing against having useful functions, but am very opposed to give a different meaning to a |
I take back "type piracy". Real type piracy is even necessary sometimes, so it's not bad in itself, and this is not my actual point here.
Sure, but in this case there is nothing special about
I don't follow. If I understand correctly, |
Ok, I didn't quite understand that the issue is related only to something added yesterday. So I have a tendency to slightly agree with @rfourquet that this can be removed, at least until it becomes absolutely necessary. But it might be tied up with some other issues @thofma is trying to resolve, so I'll wait until we have a clear concensus before merging this. |
This is commiting "type-piracy".
This method is already defined in Base and gives a different result,
i.e. vcat on a Vector returns another Vector equal to the input.
Similar for hcat.