Hi, i just made this package while porting some packages to use the new extensions feature of julia 1.9.
The package has utilities to port pkgs to the new extension system, it tries to catch all the current cases (extension from scratch, compatibility with
Requires.jl and transitioning from unconditional dependency to extension).
for example, you could define a function that is dependent on an extension being loaded or not:
function plotthing(x::Thing) ext = try_extension(@__MODULE__(),:ThingsPlotsExt) #will fail with an `ExtensionError` if the module is not found ext.__plot(x) end
Or, for packages that define types inside the package whose methods are loaded after an extension is loaded:
struct ForwardDiffThingMethod x::Symbol function ForwardDiffThingMethod(x) assert_extension(@__MODULE__(),:ThingsForwardDiffExt, err_msg = "You need to load ForwardDiff.jl to use this function") return new(x) end end
- is this useful for some people?. it is based on my (limited) experience porting pkgs to use extensions, but of course, there are other solutions.
- do i release this? or it is better to merge this in another package?. I know of PackageExtensionTools.jl and its plan to be merged into Requires.jl, but i think that this package covers a more manual niche.