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 dict comprehension construction in favor for Generator #16510

Closed
dhoegh opened this issue May 22, 2016 · 2 comments
Closed

Deprecate dict comprehension construction in favor for Generator #16510

dhoegh opened this issue May 22, 2016 · 2 comments
Milestone

Comments

@dhoegh
Copy link
Contributor

dhoegh commented May 22, 2016

As the new Generator syntax matches nicely with the construction of dictionaries. I propose using generators instead of using the comprehensions syntax to construct dictionaries as the generator syntax is closer to the syntax for manually initialization of the dictionaries. This should be deprecated:

julia> [i=>i*2 for i=1:2]
Dict{Int64,Int64} with 2 entries:
  2 => 4
  1 => 2

In favor for:

julia> Dict(i=>i*2 for i=1:2)
Dict{Int64,Int64} with 2 entries:
  2 => 4
  1 => 2

The deprecation will match the deprecation in:

julia> [1=>2, 2=>4]

WARNING: deprecated syntax "[a=>b, ...]" at REPL[53]:1.
Use "Dict(a=>b, ...)" instead.
Dict{Int64,Int64} with 2 entries:
  2 => 4
  1 => 2
@dhoegh dhoegh changed the title Deprecate dict comprehension construction infavor for Generator Deprecate dict comprehension construction in favor for Generator May 22, 2016
@JeffBezanson JeffBezanson added this to the 0.5.0 milestone May 22, 2016
JeffBezanson added a commit that referenced this issue May 25, 2016
deprecate dict comprehension syntax. fixes #16510
@blakejohnson
Copy link
Contributor

This could use an entry in NEWS.md

@tkelman
Copy link
Contributor

tkelman commented Aug 3, 2016

fc3cbc9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants