# \[RFC\] ExtensionsExt.jl : boilerplate for 1.9 extensions

**URL:** <https://discourse.julialang.org/t/rfc-extensionsext-jl-boilerplate-for-1-9-extensions/99586>\
**Category:** Package Announcements\
**Tags:** package-extensions\
**Created:** [May 30, 2023, 5:27am UTC](https://discourse.julialang.org/t/rfc-extensionsext-jl-boilerplate-for-1-9-extensions/99586 "2023-05-30T05:27:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [May 30, 2023, 5:27am UTC](https://discourse.julialang.org/t/rfc-extensionsext-jl-boilerplate-for-1-9-extensions/99586/1 "2023-05-30T05:27:45Z")

</div>

Hi, i just made this package while porting some packages to use the new extensions feature of julia 1.9.

> **[GitHub - longemen3000/ExtensionsExt.jl: Some boilerplate functions for pkg...](https://github.com/longemen3000/ExtensionsExt.jl)**
>
> Some boilerplate functions for pkg extensions. Contribute to longemen3000/ExtensionsExt.jl development by creating an account on GitHub.

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:

```julia
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:

```julia
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

```

some questions:

- 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.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [May 30, 2023, 5:56am UTC](https://discourse.julialang.org/t/rfc-extensionsext-jl-boilerplate-for-1-9-extensions/99586/2 "2023-05-30T05:56:57Z")

</div>

I think covering all use cases as opposed to just the Requires.jl version is a great idea! But in the interest of discoverability / maintainability, maybe you and @cjdoris could collaborate on a single package?
