FWIW, I think you should just depend on 1.1, eg specify something like
[compat]
julia = "1.1"
in your Project.toml. This is what I am doing for almost all of my packages (yes, I love Base.@kwdef too, and I am removing a lot of workarounds as the 1.1 compiler is so much smarter than 1.0).
Generally, it is my impression that features will not be backported, just critical bug fixes. Which is as it should be: with a lot of backports, one could hardly commit to keep a branch “stable”.
That is an interesting trail of posts. This comment here is particularly interesting:
I think we can hope that when 1.2 comes out that 1.1 becomes the new LTS branch and then we get all the benefits of 1.1 without needing to worry about 1.0
Yeah. I am already working on v1.1 and love it. The issue is there are features in v1.1 that I want to use, e.g. Base.@kwdef, that work on v1.1. but NOT on v1.0 so if I use those features, I need to worry about people still using v1.0
I think that’s the wrong way to think about it. You are writing free software, effectively donating your time and effort to other people who use the result. Your time and resources are finite, so you should be economizing on them.
If using new features of Julia makes your life a bit more convenient, you will have time to work on other stuff that benefits your users. Sensible users would recognize that they should do their part by keeping up with the latest stable release (with a reasonable lag, eg 1-2 weeks).
I totally agree with Tamas. However, if you must have 1.0, then you can use Parameters.jl whose @with_kw is essentially the same as @kwdef. You could require Parameters for 1.0 and do const @kwdef = Parameters.@with_kw and in 1.1 const @kwdef = Base.@kwdef.
help?> Base.@kwdef
@kwdef typedef
This is a helper macro that automatically defines a keyword-based constructor for the type declared in
...
Examples
≡≡≡≡≡≡≡≡≡≡
julia> Base.@kwdef struct Foo
a::Int = 1 # specified default
b::String # required keyword
end
Foo
...
julia> versioninfo()
Julia Version 1.0.0
but maybe has gotten new features / bugfixes in 1.1.
It did, if I remember correctly it was for handling parametric types. The macro exists in 1.0, but it is not practically useful outside a few narrow contexts.