The amount we can re-use old syntax for new purposes is limited: we need one
release in which the old syntax generates a warning, and then the new meaning
can arrive in the next release. Otherwise, code that worked on 0.3 might
exhibit surprising failures in the cases where the new meaning doesn't
generate an error but it is not what the programmer initially intended.
--Tim
On Wednesday, September 02, 2015 04:49:01 PM Phil Tomson wrote:
> On Wednesday, September 2, 2015 at 11:21:35 AM UTC-7, Erik Schnetter wrote:
> > If I recall correctly, the two sets of ASCII bracketing operators ([] and
> > {}) were deemed to be more usefully employed for arrays;
>
> How has have the curly braces "{" and "}" been reused for arrays in 0.4?
> Curly braces have been used to indicate Dicts up until 0.4 (and the syntax
> was essentially borrowed from Python/Ruby/others) I have to agree with the
> OP and others here that the verbose Dict syntax in 0.4 is pretty ugly. I
> didn't realize that was the way it was headed as I haven't done much in 0.4
> yet.
>
> > On Wed, Sep 2, 2015 at 1:29 PM, Michael Francis <[email protected]
> >
> > <javascript:>> wrote:
> >> The arguments given in the thread that Dict 'isn't special' should also
> >> also apply to Vector and Array, I presume nobody wants to do away with
> >> literal syntax for them as well?
> >>
> >> There are many times when having a simple terse native (code editor
> >> aware) literal syntax for structured data is very useful (in the same way
> >> that it is useful for vectors and arrays) and I second what David is
> >> saying, it feel like I'm back writing C++/C#/Java et al.
> >>
> >> Using macros works, but everybody is going to have their own so there
> >> will be no consistency across the code base. Dict(...) works without the
> >> types so I guess that is the best of a bad bunch.
> >>
> >> On Wednesday, September 2, 2015 at 1:07:59 PM UTC-4, Isaiah wrote:
> >>> This issue was raised here:
> >>> https://github.com/JuliaLang/julia/issues/6739#issuecomment-120149597
> >>>
> >>> I believe the consensus was that nice JSON input syntax could be handled
> >>> with a macro.
> >>>
> >>> Also, once the "[ a=>b, ...]" syntax deprecation goes away, I believe
> >>>
> >>> this:
> >>> [ :col => "l1", :col => "l2", ... ]
> >>>
> >>> will simply give you an array of Pair objects, which could be translated
> >>> to unitary Dicts by JSON.
> >>>
> >>> (FWIW, it is not necessary to specify the argument types to Dict)
> >>>
> >>> On Wed, Sep 2, 2015 at 12:45 PM, Michael Francis <[email protected]>
> >>>
> >>> wrote:
> >>>> With the change to 0.4 happening soon I'm finding the the new Dict
> >>>> syntax in 0.4 (removal of {}, []) is extremely verbose.
> >>>>
> >>>> I find myself interfacing with JSON APIs frequently, for example a
> >>>> configuration dictionary :
> >>>>
> >>>> data = {
> >>>>
> >>>> :displayrows => 20,
> >>>> :cols => [
> >>>> :
> >>>> { :col => "l1" },
> >>>> { :col => "l2" },
> >>>> { :col => "l3" },
> >>>> { :col => "num", :display => true },
> >>>> { :col => "sum", :display => true, :conf => {
> >>>> :style
> >>>>
> >>>> => 1, :func => { :method => "sum", :col => "num" } } }
> >>>>
> >>>> ]
> >>>>
> >>>> ... # Lots more
> >>>>
> >>>> }
> >>>>
> >>>> becomes -
> >>>>
> >>>> data = Dict{Symbol,Any}(
> >>>>
> >>>> :displayrows => 20,
> >>>> :cols => [
> >>>> :
> >>>> Dict{Symbol,Any}( :col => "l1" ),
> >>>> Dict{Symbol,Any}( :col => "l2" ),
> >>>> Dict{Symbol,Any}( :col => "l3" ),
> >>>> Dict{Symbol,Any}( :col => "num", :display => true
> >>>>
> >>>> ),
> >>>>
> >>>> Dict{Symbol,Any}( :col => "sum", :display => true,
> >>>> :
> >>>> :conf => Dict{Symbol,Any}( :style => 1,
> >>>> :
> >>>> :fu
> >>>> :nc
> >>>>
> >>>> => Dict{Symbol,Any}( :method => "sum", :col => "num" ) ) )
> >>>>
> >>>> ]
> >>>>
> >>>> ... # Lots more
> >>>>
> >>>> )
> >>>>
> >>>> This feels like asking a person using arrays to write the following
> >>>>
> >>>> Array{Int64,2}( Vector{Int64}( 1,2,3), Vector{Int64}( 4,5,6) )
> >>>>
> >>>> vs
> >>>>
> >>>> [ [ 1, 2, 3] [ 4,5,6 ] ]
> >>>>
> >>>> Can we please reconsider ?