Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-08 Thread Jeffrey Sarnoff
Do others get this warning? If so, what modification of Mike's macro avoids it? WARNING: deprecated syntax "{a,b, ...}". Use "Any[a,b, ...]" instead. On Thursday, September 3, 2015 at 8:12:50 PM UTC-4, Jeffrey Sarnoff wrote: > > tip o' hat to that > > this minor edit, omitting {Any,Any}

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-08 Thread Michael Turok
That is elegantif I only could follow how it works On Thursday, September 3, 2015 at 4:40:54 PM UTC-4, Mike Innes wrote: > > FWIW I mocked up a json syntax macro: > > using MacroTools, Lazy > > import MacroTools: prewalk > > function prockey(key) > @capture(key, (a_:b_) | (a_=>b_)) ||

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Kevin Squire
Relevant Julia issues: * Reintroduce concise syntax for Dict construction? #12930 * Dict syntax is getting me down #6739 On Thu, Sep 3, 2015 at 7:38 AM, Jeff Bezanson

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Steven G. Johnson
On Thursday, September 3, 2015 at 10:38:15 AM UTC-4, Jeff Bezanson wrote: > > There is no need to write the type over and over again. You can say > > const D = Dict{Symbol, Any} > > D(:a => "", :b => 0, ...) > There is also often no need to write the type at all: julia> Dict(:a => "", :b

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Jeff Bezanson
There is no need to write the type over and over again. You can say const D = Dict{Symbol, Any} D(:a => "", :b => 0, ...) The old syntax for this was (Symbol=>Any)[:a => "", :b => 0, ...] but there was no way to abstract over the type part, `(Symbol=>Any)`, so you really did have to write the

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Tim Holy
The motivation for this change is so people can more easily construct arrays- of-arrays. In the future, [1:10] will construct a Vector{UnitRange{Int}}, not a Vector{Int}. [1:10;] is concatenating and makes a Vector{Int}. (The first does too, but we need a release cycle with deprecation warnings

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Mike Nolta
I also think ditching {} for dicts wasn't a great idea. -Mike On Thu, Sep 3, 2015 at 9:36 AM, Jonathan Malmaud wrote: > I agree that syntactic sugar for Dict literal construction would be > appreciated. There were good reasons for removing the previous syntax, but I > think

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Jeff Bezanson
For `[1:10]`, I recommend `collect(1:10)` or `[1:10;]`. Splatting should be avoided where possible. On Thu, Sep 3, 2015 at 11:22 AM, wrote: > Early adopters shouldn't throw stones... :) But in fact I quite like the new > Dict syntax, which seems to be more explicit and

[julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread cormullion
Early adopters shouldn't throw stones... :) But in fact I quite like the new Dict syntax, which seems to be more explicit and readable. Curly braces seem to be gainfully employed elsewhere doing type stuff. And experts can make short cuts, either in Julia or in their editors... I confess I'm a

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
There are a number of inconsistency problems currently though. [1,2.3,4] gives Array{Float64,1}, but Dict(1=>1,2=>2.3,3=>3) gives Dict{Int64,Any}. Another weird one with arrays that is inconsistent (hopefully will be fixed in 0.5): [1,2,[3,4]] gives a deprecation warning about concatenation,

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Jeff Bezanson
> Another weird one with arrays that is inconsistent (hopefully will be fixed > in 0.5) Yes that's the whole point of the deprecation warning. On Thu, Sep 3, 2015 at 11:01 AM, Scott Jones wrote: > There are a number of inconsistency problems currently though. > >

[julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
On Thursday, September 3, 2015 at 12:20:51 PM UTC-4, cormu...@mac.com wrote: > > "Why is [1:10...] a puzzle?" > > Just that a new user might expect to see or use the ellipsis in its > conventional position: > > [1...10] > [1...10] may be conventional outside of julia (is that done in other

[julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread cormullion
"Why is [1:10...] a puzzle?" Just that a new user might expect to see or use the ellipsis in its conventional position: [1...10] rather than at the end: [1:10...]

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
On Thursday, September 3, 2015 at 1:47:07 PM UTC-4, Sean Marshallsay wrote: > > [1:10;] is simply a consequence of matrix literal syntax (like [1:10; > 11:20]) and gets translated into vcat(1:10). It might be a bit confusing > but there's no point in making it a special case > Yes, I

[julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
On Thursday, September 3, 2015 at 11:22:09 AM UTC-4, cormu...@mac.com wrote: > > Early adopters shouldn't throw stones... :) But in fact I quite like the > new Dict syntax, which seems to be more explicit and readable. Curly braces > seem to be gainfully employed elsewhere doing type stuff.

[julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
On Thursday, September 3, 2015 at 11:22:09 AM UTC-4, cormu...@mac.com wrote: > > Early adopters shouldn't throw stones... :) But in fact I quite like the > new Dict syntax, which seems to be more explicit and readable. Curly braces > seem to be gainfully employed elsewhere doing type stuff.

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
To me, the use of ; within [ ] seems pretty confusing. Elsewhere in Julia, it seems to mean, throw away the result, so I would have expected [1:10; ] to be equivalent to []. Why is [1:10;] (confusing, ; is not consistent with any other uses in Julia), preferred over [1:10...] (easy to

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Sean Marshallsay
[1:10;] is simply a consequence of matrix literal syntax (like [1:10; 11:20]) and gets translated into vcat(1:10). It might be a bit confusing but there's no point in making it a special case. On Thursday, 3 September 2015 17:28:27 UTC+1, Scott Jones wrote: > > To me, the use of ; within [ ]

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
Another use is marking off the keyword arguments or parameters. On Thursday, September 3, 2015 at 3:11:34 PM UTC-4, Jonathan Malmaud wrote: > > What are the other uses of ; in Julia? I can only think of suppressing > output on the REPL and separating expressions on a single line - neither >

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Michael Francis
That's really quite nice and for the purpose of interfacing with JSON is certainly clearer. On Thursday, September 3, 2015 at 4:40:54 PM UTC-4, Mike Innes wrote: > > FWIW I mocked up a json syntax macro: > > using MacroTools, Lazy > > import MacroTools: prewalk > > function prockey(key) >

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Mike Innes
FWIW I mocked up a json syntax macro: using MacroTools, Lazy import MacroTools: prewalk function prockey(key) @capture(key, (a_:b_) | (a_=>b_)) || error("Invalid json key $key") isa(a, Symbol) && (a = Expr(:quote, a)) :($a=>$b) end function procmap(d) @capture(d, {xs__}) || return d

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Scott Jones
I must say, that's beautiful! I hope I can figure out just how it is doing it's magic, as I didn't think macros could change the way things like { } and : were handled.  On Thursday, September 3, 2015 at 4:40:54 PM UTC-4, Mike Innes wrote: > > FWIW I mocked up a json syntax macro: > > using

Re: [julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Jeffrey Sarnoff
tip o' hat to that this minor edit, omitting {Any,Any} (following Jeff B's note) gives back some autotyping function procmap(d) @capture(d, {xs__}) || return d :(Dict($(map(prockey, xs)...))) end On Thursday, September 3, 2015 at 4:40:54 PM UTC-4, Mike Innes wrote:

[julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-03 Thread Jonathan Malmaud
I agree that syntactic sugar for Dict literal construction would be appreciated. There were good reasons for removing the previous syntax, but I think it should be possible to find something more terse than the status quo. On Wednesday, September 2, 2015 at 12:45:08 PM UTC-4, Michael Francis

[julia-users] Re: The new Dict syntax in 0.4 is very verbose

2015-09-02 Thread Jeffrey Sarnoff
This is an outcome of an underlying as-yet-unresolvedness, one all agree is important as it must shape some of the experience one has with Julia. Stefan makes good sense: "In Julia, [Dict is] just another data structure ... So having special syntax ends up being ... problematic and