-
-
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
RFC: regularize Dict syntax #8521
Conversation
use Dict(iter) or Dict(::Pair...) as Dict constructors ref #6739
add comparisons for Pair start fixing tests
add isless for Pair
I think let the name bikeshedding begin! How about: |
Making |
this way `a=>b` is lowered like every other operator call, except in the old dict syntax during the deprecation period. this is probably a good way to deal with it, and we can later decide to remove the `Pair` alias if we want to.
2ef98c5
to
0388647
Compare
Ready to merge pending travis. |
Exciting!! |
|
||
As with arrays, ``Dicts`` may be created with comprehensions. For example, | ||
``{i => f(i) for i = 1:10}``. | ||
``[i => f(i) for i = 1:10]``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing actual construction of Dict here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dict comprehension syntax has not been deprecated yet, since we don't have an efficient replacement. It will be Dict( i => f(x) for i = 1:10 )
. However the old syntax at least has to keep working (with a warning) through 0.4.
You decided to keep |
This separates the syntax ( |
Yes. The best part is that |
I guess it could be name |
This would read p::(A=>B) instead, which doesn't look that bad -- compare -erik On Mon, Oct 6, 2014 at 2:43 PM, Jeff Bezanson notifications@github.com
Erik Schnetter schnetter@cct.lsu.edu |
Well, then we'd be repeating the whole tuple type business over again – does |
How about calling the type |
I have no preference, |
Imagine having that conversation where you'd have to explain that the |
Yes, |
But those very same people love category theory... |
Ok, I think that |
I think |
Perhaps unsurprisingly, this broke everything - there was a delay though due to the PkgEval machine being down. Can someone who understands this better than I provide a snippet for explaining how to have the old and the new in the same code base? |
Here's one approach: JuliaGraphics/Winston.jl@9f1d9c8 |
Another: |
The reason this broke DataArrays despite the deprecation is that previously, if all keys were of type julia> [1 => 2, 2 => "a"]
Dict{Int64,Any} with 2 entries:
2 => "a"
1 => 2 with master: julia> [1 => 2, 2 => "a"]
WARNING: deprecated syntax "[a=>b, ...]".
Use "Dict(a=>b, ...)" instead.
Dict{Any,Any} with 2 entries:
2 => "a"
1 => 2 Was this an intentional change? It seems easy enough to change it back by using the same pattern for the pair constructor as for the tuple constructor. |
No, it wasn't intentional. Please change it back as you describe if you get a chance. |
Also, |
We could actually have a deprecation warning for both. The only new >1 argument form of |
Yeah, I realized that later and put deprecations for both in #8627 |
I'd say that there has been about 75% recovery already from the errors yesterday, a good chunk of the remaining are probably actually due to the removal of the range deprecations and are semi-abandoned packages. |
Out of curiosity, why was a new |
One motivation is to be able to distinguish between which syntax was used - |
Could someone take a look at the languishing PR relevant for transitioning to 0.4? Yay or nay? |
This provides
Dict(a=>b, c=>d, ...)
andDict{K,V}(a=>b, c=>d, ...)
syntax. Plan is to deprecate other dict syntax.Fixes #6739.
I think the main controversy is what exactly
=>
should be. Right now it is special syntax for a call toBase.Pair
. It could be a function, or the name of the pair type (immutable =>{A,B}
).