-
-
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
Possible source of confusion with Array constructor and parametric type #9370
Comments
I think it's a matter of documenting the distinction well. Currently, the brace notation Array{Int,2} is used in the section about arrays, but not explained there. It's explained in the section on type aliases, but that's not where beginning programmers are likely to look. I suggest adding a highlighted box to the section about arrays. The box would explain the difference between Array(Float32,10) and Array{Float32,10}, and have a hyperlink back to the type aliases section. |
I agree that this is confusing. Coming from MATLAB, I found the declaration of Arrays initially very confusing. Especially since the easiest way to start is array = Int64[] It is more verbose and confusing to use array = Array(Int64, 1) Personally, I think the section julia> Array[[1 2] [3 4]]
1x2 Array{Array{T,N},2}:
1x2 Array{Int64,2}:
1 2 1x2 Array{Int64,2}:
3 4
julia> typeof(array)
Array{Array{T,N},2} <= why is T here not set to Int64? I would suggest adding a brief reminder of the minimal relevant info from
|
I believe there was talk of moving Array construction from A = Array(Int, 10) to A = Array{Int}(10)
#or
A = Vector{Int}(10) This would match the |
+1 for more consistency. At least, it would be more clear if all Types followed the same convention when used in declarations. |
How do you handle tuples? Does |
Almost the same as #3214 |
|
We were talking in the JuliaOpt office (lol) about type stability, and were musing on the fact that are fairly common error is to do something like
which is under-typed, because you need the dimension as well. Why would people not use the dimension? Well, one possible confusion is:
So the "second argument" has wildly different meanings. Maybe people assume they are same? Or just don't know and punt? Or maybe when people type
Array{Int}
they think it meansVector{Int}
?Looking for any ideas about whether this is a problem, and if there is any "fix" possible.
(can also move to julia-dev if more appropriate)
The text was updated successfully, but these errors were encountered: