Methods for maintaining backwards compatibility

I’ve just improved some of the code in a package of mine, and found (from my unit testing) that it throws an error in v1.6 of Julia. I’d like to maintain compatibility with Julia 1.6 since this is the most recent LTS release. I see 3 ways to achieve this:

  1. Not make that particular change until there’s a new Julia LTS version - not ideal.
  2. Create a new minor release which drops support for Julia 1.6, but keep patching the current minor release with bug fixes too. Also not ideal, since the code may diverge, increasing the work to port patches across both (and potentially more) releases.
  3. Having a branch in the code based on the Julia version. According to this thread, this can be done as follows:

Is this still the recommended way of achieving this?

Which of the 3 approaches do you use/recommend? Does option 3 become more complicated when the required features are in a package, not core Julia itself?

Yes. In some cases you can use the Compat.jl package instead, which has these branches already written for you.

(Note that you usually don’t need the @static unless the code inside the branch has macros or similar that don’t exist in the newer version, which would prevent the code from being lowered in older versions.)

1 Like