Hello,
I didn't realize NamedArrays was broken on release-0.3, because of my lack
of travis skills. I had a different 0.4 incompatibility:
"(Dict{K,V})(ks::AbstractArray{K},vs::AbstractArray{V})
is deprecated, use (Dict{K,V})(zip(ks,vs)) instead". Foolishly I replace
my construct
Dict(keys, values)
by
@Compat.dict(zip(keys, values))
but that breaks on release-0.3.
Is there a recommended way to solve this incompatibility?
Cheers,
---david
On Saturday, October 11, 2014 8:17:38 PM UTC+2, Stefan Karpinski wrote:
>
> This announcement is primarily for Julia package developers. Since there
> is already some syntax breakage between Julia v0.3 and v0.4, and there will
> be more, it's increasingly tricky to make packages to work on both
> versions. The Compat package <https://github.com/JuliaLang/Compat.jl> was
> just created to help: it provides compatibility constructs that will work
> in both versions without warnings.
>
> For example, in v0.3 you could create a dictionary like this:
>
> julia> [ :foo => 1, :bar => 2 ]
> Dict{Symbol,Int64} with 2 entries:
> :bar => 2
> :foo => 1
>
>
> This still works in v0.4 but it produces a warning. The new syntax is this:
>
> julia> Dict(:foo => 1, :bar => 2)
> Dict{Symbol,Int64} with 2 entries:
> :bar => 2
> :foo => 1
>
>
> However, this newer syntax won't work in v0.3, so you're a bit stuck if
> you want to write a dictionary literal in a way that will work in both v0.3
> and v0.4 without producing a warning. Compat to the rescue!:
>
> julia> using Compat
>
> julia> @Compat.Dict(:foo => 2, :bar => 2)
> Dict{Symbol,Int64} with 2 entries:
> :bar => 2
> :foo => 2
>
>
> This works with no warning on both v0.3 and v0.4. We've intentionally not
> exported the Dict macro so that the usage needs to be prefixed with
> "Compat.", which will make usages of the compatibility workarounds easier
> to find and remove later when they're no longer necessary.
>
> Currently, there's only a couple of definitions in the Compat package, but
> if you have your own hacks that have helped make it easier to write
> cross-version package code, please contribute them and we can build up a
> nice little collection.
>