Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-02 Thread Stefan Karpinski
On Thu, May 1, 2014 at 11:49 PM, km srikrishnamo...@gmail.com wrote:



Yes I would say having one syntax is the best thing to do. This would be
 less confusing. More the ways of doing it more confusing the code looks.
 Too many symbols like {,},(,), decrease code readability. Which is why I
 prefer python syntax. its clean simple and easy to read.


I wasn't aware that Python had a syntax for creating typed dictionaries.


Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-02 Thread Carlo Baldassi
But what's your suggestion about typed dict comprehensions?

On Thursday, May 1, 2014 7:11:59 PM UTC+2, Stefan Karpinski wrote:

 Is be more in favor of deprecating the (K=V)[k=v] syntax and just using 
 keyword args like this Dict{K,V}(k=v). Having so many syntaxes for this is 
 confusing and it's not like the (K=V)[k=v] syntax is a thing of beauty.

 On May 1, 2014, at 12:50 PM, Jameson Nash vtj...@gmail.com javascript: 
 wrote:

 The = is special here for the parser. What you want is 
 (Int=Dict{Int, Int})[ ]

 However, it's possible your alternative syntax could be made to work. 

 On Thursday, May 1, 2014, thom lake thom@gmail.com javascript: 
 wrote:

 Both of these work

 julia Dict{Int,Int}()
 Dict{Int64,Int64}()

 julia (Int=Int)[]
 Dict{Int64,Int64}()

 So does this

 julia Dict{Int,Dict{Int,Int}}()
 Dict{Int64,Dict{Int64,Int64}}()

 This doesn't

 julia (Int=(Int=Int))[]
 ERROR: unsupported or misplaced expression =

 Any particular reason? Am I doing something silly?



Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-02 Thread Stefan Karpinski
Yeah, that I've got nothing for unless we did this:

(K,V)[ k = f(v) for (k,v) in d ]


On Fri, May 2, 2014 at 9:35 AM, Carlo Baldassi carlobalda...@gmail.comwrote:

 But what's your suggestion about typed dict comprehensions?


 On Thursday, May 1, 2014 7:11:59 PM UTC+2, Stefan Karpinski wrote:

 Is be more in favor of deprecating the (K=V)[k=v] syntax and just using
 keyword args like this Dict{K,V}(k=v). Having so many syntaxes for this is
 confusing and it's not like the (K=V)[k=v] syntax is a thing of beauty.

 On May 1, 2014, at 12:50 PM, Jameson Nash vtj...@gmail.com wrote:

 The = is special here for the parser. What you want is
 (Int=Dict{Int, Int})[ ]

 However, it's possible your alternative syntax could be made to work.

 On Thursday, May 1, 2014, thom lake thom@gmail.com wrote:

 Both of these work

 julia Dict{Int,Int}()
 Dict{Int64,Int64}()

 julia (Int=Int)[]
 Dict{Int64,Int64}()

 So does this

 julia Dict{Int,Dict{Int,Int}}()
 Dict{Int64,Dict{Int64,Int64}}()

 This doesn't

 julia (Int=(Int=Int))[]
 ERROR: unsupported or misplaced expression =

 Any particular reason? Am I doing something silly?




Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-02 Thread Stefan Karpinski
Not if we took the {} syntax for empty dict, but this is becoming a rather
disruptive change.


On Fri, May 2, 2014 at 11:48 AM, Mike Nolta m...@nolta.net wrote:

 But then it's unclear if (A,(B,C))[] is Dict{A,Dict{B,C}} or Dict{A,(B,C)}.

 -Mike

 On Fri, May 2, 2014 at 11:26 AM, Stefan Karpinski ste...@karpinski.org
 wrote:
  Yeah, that I've got nothing for unless we did this:
 
  (K,V)[ k = f(v) for (k,v) in d ]
 
 
  On Fri, May 2, 2014 at 9:35 AM, Carlo Baldassi carlobalda...@gmail.com
  wrote:
 
  But what's your suggestion about typed dict comprehensions?
 
 
  On Thursday, May 1, 2014 7:11:59 PM UTC+2, Stefan Karpinski wrote:
 
  Is be more in favor of deprecating the (K=V)[k=v] syntax and just
 using
  keyword args like this Dict{K,V}(k=v). Having so many syntaxes for
 this is
  confusing and it's not like the (K=V)[k=v] syntax is a thing of
 beauty.
 
  On May 1, 2014, at 12:50 PM, Jameson Nash vtj...@gmail.com wrote:
 
  The = is special here for the parser. What you want is
  (Int=Dict{Int, Int})[ ]
 
  However, it's possible your alternative syntax could be made to work.
 
  On Thursday, May 1, 2014, thom lake thom@gmail.com wrote:
 
  Both of these work
 
  julia Dict{Int,Int}()
  Dict{Int64,Int64}()
 
  julia (Int=Int)[]
  Dict{Int64,Int64}()
 
  So does this
 
  julia Dict{Int,Dict{Int,Int}}()
  Dict{Int64,Dict{Int64,Int64}}()
 
  This doesn't
 
  julia (Int=(Int=Int))[]
  ERROR: unsupported or misplaced expression =
 
  Any particular reason? Am I doing something silly?
 
 



Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-01 Thread Jameson Nash
The = is special here for the parser. What you want is
(Int=Dict{Int, Int})[ ]

However, it's possible your alternative syntax could be made to work.

On Thursday, May 1, 2014, thom lake thom.l.l...@gmail.com wrote:

 Both of these work

 julia Dict{Int,Int}()
 Dict{Int64,Int64}()

 julia (Int=Int)[]
 Dict{Int64,Int64}()

 So does this

 julia Dict{Int,Dict{Int,Int}}()
 Dict{Int64,Dict{Int64,Int64}}()

 This doesn't

 julia (Int=(Int=Int))[]
 ERROR: unsupported or misplaced expression =

 Any particular reason? Am I doing something silly?




Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-01 Thread thom lake
Agreed. Initialization continues to send me running for the REPL. For 
example (Int)[], Array(Int,0), Array{Int,1}(). The later doesn't work, but 
I always want to type it. I kind of like the (K=V)[] syntax, but wouldn't 
be sad to see it go if it meant less confusion.

On Thursday, May 1, 2014 1:11:59 PM UTC-4, Stefan Karpinski wrote:

 Is be more in favor of deprecating the (K=V)[k=v] syntax and just using 
 keyword args like this Dict{K,V}(k=v). Having so many syntaxes for this is 
 confusing and it's not like the (K=V)[k=v] syntax is a thing of beauty.

 On May 1, 2014, at 12:50 PM, Jameson Nash vtj...@gmail.com javascript: 
 wrote:

 The = is special here for the parser. What you want is 
 (Int=Dict{Int, Int})[ ]

 However, it's possible your alternative syntax could be made to work. 

 On Thursday, May 1, 2014, thom lake thom@gmail.com javascript: 
 wrote:

 Both of these work

 julia Dict{Int,Int}()
 Dict{Int64,Int64}()

 julia (Int=Int)[]
 Dict{Int64,Int64}()

 So does this

 julia Dict{Int,Dict{Int,Int}}()
 Dict{Int64,Dict{Int64,Int64}}()

 This doesn't

 julia (Int=(Int=Int))[]
 ERROR: unsupported or misplaced expression =

 Any particular reason? Am I doing something silly?



Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-01 Thread Kevin Squire
In https://github.com/JuliaLang/julia/issues/4871, I suggested Dict(K,V) for
constructor syntax, so that it matches Array(Int) construction syntax.  My
understanding was that there's a slight issue with the way that Dicts are
used internally that would require some changes, but that it's generally
doable.

That issue, as written, is somewhat confusing, so it's probably worth
opening up a separate issue about this.

Cheers,
   Kevin


On Thu, May 1, 2014 at 10:56 AM, thom lake thom.l.l...@gmail.com wrote:

 Agreed. Initialization continues to send me running for the REPL. For
 example (Int)[], Array(Int,0), Array{Int,1}(). The later doesn't work,
 but I always want to type it. I kind of like the (K=V)[] syntax, but
 wouldn't be sad to see it go if it meant less confusion.

 On Thursday, May 1, 2014 1:11:59 PM UTC-4, Stefan Karpinski wrote:

 Is be more in favor of deprecating the (K=V)[k=v] syntax and just using
 keyword args like this Dict{K,V}(k=v). Having so many syntaxes for this is
 confusing and it's not like the (K=V)[k=v] syntax is a thing of beauty.

 On May 1, 2014, at 12:50 PM, Jameson Nash vtj...@gmail.com wrote:

 The = is special here for the parser. What you want is
 (Int=Dict{Int, Int})[ ]

 However, it's possible your alternative syntax could be made to work.

 On Thursday, May 1, 2014, thom lake thom@gmail.com wrote:

 Both of these work

 julia Dict{Int,Int}()
 Dict{Int64,Int64}()

 julia (Int=Int)[]
 Dict{Int64,Int64}()

 So does this

 julia Dict{Int,Dict{Int,Int}}()
 Dict{Int64,Dict{Int64,Int64}}()

 This doesn't

 julia (Int=(Int=Int))[]
 ERROR: unsupported or misplaced expression =

 Any particular reason? Am I doing something silly?




Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-01 Thread Jacob Quinn
I've always kind of wanted {} for initializing a Dict, a la Python. Is
there really any difference between Any[] and {}? Do we really need {} for
Any arrays? I think it would be much easier if square brackets [] were
always array-type things, and {} were Dict things.

-Jacob


On Thu, May 1, 2014 at 6:20 PM, Kevin Squire kevin.squ...@gmail.com wrote:

 In https://github.com/JuliaLang/julia/issues/4871, I suggested Dict(K,V) for
 constructor syntax, so that it matches Array(Int) construction syntax.
  My understanding was that there's a slight issue with the way that Dicts
 are used internally that would require some changes, but that it's
 generally doable.

 That issue, as written, is somewhat confusing, so it's probably worth
 opening up a separate issue about this.

 Cheers,
Kevin



 On Thu, May 1, 2014 at 10:56 AM, thom lake thom.l.l...@gmail.com wrote:

 Agreed. Initialization continues to send me running for the REPL. For
 example (Int)[], Array(Int,0), Array{Int,1}(). The later doesn't work,
 but I always want to type it. I kind of like the (K=V)[] syntax, but
 wouldn't be sad to see it go if it meant less confusion.

 On Thursday, May 1, 2014 1:11:59 PM UTC-4, Stefan Karpinski wrote:

 Is be more in favor of deprecating the (K=V)[k=v] syntax and just
 using keyword args like this Dict{K,V}(k=v). Having so many syntaxes for
 this is confusing and it's not like the (K=V)[k=v] syntax is a thing of
 beauty.

 On May 1, 2014, at 12:50 PM, Jameson Nash vtj...@gmail.com wrote:

 The = is special here for the parser. What you want is
 (Int=Dict{Int, Int})[ ]

 However, it's possible your alternative syntax could be made to work.

 On Thursday, May 1, 2014, thom lake thom@gmail.com wrote:

 Both of these work

 julia Dict{Int,Int}()
 Dict{Int64,Int64}()

 julia (Int=Int)[]
 Dict{Int64,Int64}()

 So does this

 julia Dict{Int,Dict{Int,Int}}()
 Dict{Int64,Dict{Int64,Int64}}()

 This doesn't

 julia (Int=(Int=Int))[]
 ERROR: unsupported or misplaced expression =

 Any particular reason? Am I doing something silly?





Re: [julia-users] Initialize dict of dicts with = syntax

2014-05-01 Thread Stefan Karpinski
I've always thought it was a bit gratuitous, but I never used cell arrays in 
Matlab.

 On May 1, 2014, at 8:07 PM, Jacob Quinn quinn.jac...@gmail.com wrote:
 
 I've always kind of wanted {} for initializing a Dict, a la Python. Is there 
 really any difference between Any[] and {}? Do we really need {} for Any 
 arrays? I think it would be much easier if square brackets [] were always 
 array-type things, and {} were Dict things.
 
 -Jacob
 
 
 On Thu, May 1, 2014 at 6:20 PM, Kevin Squire kevin.squ...@gmail.com wrote:
 In https://github.com/JuliaLang/julia/issues/4871, I suggested Dict(K,V) for 
 constructor syntax, so that it matches Array(Int) construction syntax.  My 
 understanding was that there's a slight issue with the way that Dicts are 
 used internally that would require some changes, but that it's generally 
 doable.
 
 That issue, as written, is somewhat confusing, so it's probably worth 
 opening up a separate issue about this.
 
 Cheers,
Kevin
 
 
 
 On Thu, May 1, 2014 at 10:56 AM, thom lake thom.l.l...@gmail.com wrote:
 Agreed. Initialization continues to send me running for the REPL. For 
 example (Int)[], Array(Int,0), Array{Int,1}(). The later doesn't work, but 
 I always want to type it. I kind of like the (K=V)[] syntax, but wouldn't 
 be sad to see it go if it meant less confusion.
 
 On Thursday, May 1, 2014 1:11:59 PM UTC-4, Stefan Karpinski wrote:
 Is be more in favor of deprecating the (K=V)[k=v] syntax and just using 
 keyword args like this Dict{K,V}(k=v). Having so many syntaxes for this is 
 confusing and it's not like the (K=V)[k=v] syntax is a thing of beauty.
 
 On May 1, 2014, at 12:50 PM, Jameson Nash vtj...@gmail.com wrote:
 
 The = is special here for the parser. What you want is 
 (Int=Dict{Int, Int})[ ]
 
 However, it's possible your alternative syntax could be made to work. 
 
 On Thursday, May 1, 2014, thom lake thom@gmail.com wrote:
 Both of these work
 
 julia Dict{Int,Int}()
 Dict{Int64,Int64}()
 
 julia (Int=Int)[]
 Dict{Int64,Int64}()
 
 So does this
 
 julia Dict{Int,Dict{Int,Int}}()
 Dict{Int64,Dict{Int64,Int64}}()
 
 This doesn't
 
 julia (Int=(Int=Int))[]
 ERROR: unsupported or misplaced expression =
 
 Any particular reason? Am I doing something silly?