Skip to content
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

deprecate zero-arg Vector constructor #22717

Closed
wants to merge 1 commit into from

Conversation

fredrikekre
Copy link
Member

@ararslan ararslan added arrays [a, r, r, a, y, s] deprecation This change introduces or involves a deprecation labels Jul 9, 2017
@nalimilan
Copy link
Member

I'm not sure I like this idea. Yes, that would be more consistent with Matrix{T}() throwing an error, but Vector{T}() is quite natural and very common...

@mauro3
Copy link
Contributor

mauro3 commented Jul 9, 2017

I think the most natural for Vector{T}() is T[], so making this consistent will at least not impact my code. In fact, maybe this PR could use the T[] form where appropriate?

@fredrikekre
Copy link
Member Author

I'm not sure I like this idea. Yes, that would be more consistent with Matrix{T}() throwing an error, but Vector{T}() is quite natural and very common...

I like the consistency, but on the other hand, an empty vector is useful which a empty matrix really isn't, so that could warrant special treatment of Vector()...

I think the most natural for Vector{T}() is T[], so making this consistent will at least not impact my code. In fact, maybe this PR could use the T[] form where appropriate?

I included the [] / T[] syntax as a suggestion in the deprecation warning, I also think [] / T[] is nicer than Vector() / Vector{T}().

@rfourquet
Copy link
Member

rfourquet commented Jul 9, 2017

Another consistency would be broken with this PR when we see Vector as the general go-to container (the list of python, std::vector of C++ etc.), in the same family as other general containers like Set, rather than as a member of multi-dim arrays; then it's natural that a call to the type with no argument constructs an empty container. Consider e.g.

T = rand(Bool) ? Vector{Int} : Set{Int}
c = T()

Similarly, Vector() should not be deprecated IMHO, by analogy to Set().

@fredrikekre
Copy link
Member Author

This is a bad idea, I kinda like Vector{T}() to make a new empty vector, and people seem to agree with me, so I'll close this, and also #21082 and put this issue at a rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] deprecation This change introduces or involves a deprecation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants