-
-
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
Dict syntax is difficult to remember #2067
Comments
I rather like the current syntax. You can still create Dict's via |
I don't think that I agree that it's a bit unfortunate that the syntax |
I never used MATLAB, I didn't know the syntax
But, after try one time on the list, I get the answer I don't have this problem anymore. I didn't think on Dict Maybe a better error message in
can help to the cause too. Maybe there is not a better option for Dicts... But the actual syntax was a little hard for me at first moment. I'm affray It is going to be hard to future users too :/ And first moments comes back when someone take distance for the language a couple of months sometimes. But... Maybe what we need is both things |
This defines julia> a = Vector{Int}
Array{Int64,1}
julia> typeof(a)
CompositeKind
julia> b = Array(Int, 0)
0-element Int64 Array
julia> typeof(b)
Array{Int64,1}
julia> a == typeof(b)
true In Julia you can do operations on types. That's truly awesome (and it lies at the core of how it's implemented), but you have to make sure you keep the distinction firmly in mind. |
I would agree, however, that users coming from other languages can struggle in the early days with how to declare things---speaking for myself, at least. At one point I started contributing a bunch of exercises to go along with the manual. I think they were causing some sort of trouble and ended up getting deleted or commented out, but perhaps we should resurrect and expand upon them. |
The links to them didn't work and I couldn't quite figure out how to make them work at the time, so rather than leaving a lot of dangling links in the manual, I commented out the links. Recently, when Viral went through the manual, cleaning things up, I believe he may have removed the files. We could resurrect them with some spiffing up. |
I'll point out that they definitely won't help with the Dict syntax though since that was added long after the examples were written. |
I didn't mean to imply that my exercises were all that great, simply that this kind of trouble is one that having exercises might really help with. There's lots of evidence that "testing" helps learning. If others agree with the principle, certainly we can start from scratch or expand upon them mightily. |
How about something like
It is also nice to associate the type with [pao: Use backticks for inline code snippets; triple backticks each on their own line for blocks] |
I don't really think that Dict syntax needs any more changes. It's a little complicated, but that's what happens when you have a sophisticated type system. Just use |
Dict syntax has more than one option, and declaration of types doesn't match with other constructors on Julia.
Maybe the most confusing thing is
(KeyType=>ValueType)[...]
because doesn't match withDict{K,V}(n)
and others constructors.Having
[...]
or{...}
is confusing too.Maybe can be a little more simple, something like:
What do you think?
The text was updated successfully, but these errors were encountered: