-
-
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
Inconsistency in constructing Dict and Array #3214
Comments
Related to #2067 |
Some other confusing (to me at least) behaviors:
and
|
The |
I can see why you might want to go wait until you can have constructors for partially-instantiated types; but maybe explicit is better than implicit here? Dynamically growing Arrays (Vectors in C++ lingo) are implemented really different from fixed-size Arrays (I didn't look at julias implementation but I guess it uses the conventional size & capacity book keeping?). Giving them a different name would make that very transparent, while functions can still be developed against a common abstract supertype. |
There would be some advantages to having growable vectors separate from non-growable multi-dimensional arrays. But you would still be left without the syntax |
I think not having the syntax |
This should be affected by plans in #1470. |
We have an update here! It is now possible to define constructors for
I think it would be better to use |
Nice! How does it conflict? In |
It's only a slight conflict. The problems would start if we wanted to be able to convert a number to a 1-element array. It wouldn't be clear what |
I see. I don't think there's a problem with numerical constants (just pick a behavior), but I can see an issue in code where, e.g., Array{Int}(a) to be consistent. |
Numbers pretending to be containers strikes again. |
Could that behavior go away in 0.4? |
I don't really think numbers pretend to be containers. If we had a |
They support |
There are functions that don't treat numbers like containers, e.g.
|
Anyway it doesn't make much sense to try converting a |
Both Dict and Array are parametric types. Constructing a Dict and an Array of variable size differs markedly, though:
*
Dict{TypeA,TypeB}()
*
Array(Type)
whileArray{Type}()
doesn't workThis creates some confusion for people new to the language – also I think its inconsistent design.
The text was updated successfully, but these errors were encountered: