-
-
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
remove Vector{T}()
constructor?
#21082
Comments
This is expected. This is the difference between creating a zero-dimensional array (which has size That said, the existence of the |
Vector{T}()
Ai,...it makes sense as |
I feel that I think that the moment when we implement What I see here which seems wrong is that the empty |
I agree with @andyferris that the implicit 0-d array constructor |
Vector{T}()
Arrayr{T}()
The |
Then I would argue to remove the calls of |
I would imagine we'll be keeping |
+1 for the idea suggested by @H-225. I often construct empty 1-D Arrays and almost never 0-D Arrays, so this syntax could be more convenient. (I know, we use numbers all the time, but we tell Julia that they are things like Float64 or not Array{Float64, 0}. Given the new broadcasting syntax, I don't see that we would ever need a 0-d Array |
All the array constructors take either a size tuple or an argument list of dimension lengths. If you omit the dimensionality in the type, then the dimensionality is simply the length of the tuple or number of arguments. If you include the dimensionality, then the arguments must match. I'd argue that this case is distinctly different from the constructors for other resizable collections because those constructors frequently take an iterable list of contents for them to contain. In that case it makes a lot more sense that a no-argument default is an empty collection. I think the solution here is the deprecation of |
I take your point, @mbauman. I had forgotten about the possibility of |
So the "functional" (as opposed to "literal") syntax would be
Ah, that's very true - I was thinking of the tuple form (e.g.
That's an interesting one - turning this on its head, why shouldn't |
The latter is mildly exceptional, but seems practical and commonly used. I don't really see why it's a pants on fire issue to delete this method. |
This is my point earlier. It would go away naturally if/when |
Arrayr{T}()
Vector{T}()
constructor?
Closing this, given #22717 |
Actually, I have no idea why this thread got evolved from removing My original idea was to remove - EDIT: just re-read above, my mind was also changing, I did mention removing |
Agreed, |
Removing only Please do not open a new issue that suggests only removing |
Fair point, I will not pursue the issue further. However, I am curious is there actually a use case for zero-dimensional array's which is not more appropriately a |
There are couple of moments that I needed to create empty arrays (vectors) and wrote Ya, deprecating all |
If we eliminated |
I suppose that we could only allow |
Not sure if they are the expected results, but I did expect that
length(Array{Any}()) = 0
The text was updated successfully, but these errors were encountered: