How do I actually use package extensions?

Say I wish to use ForwardDiffs static arrays extension.

I can do:
using ForwardDiff, StaticArrays

How do I actually access methods from the extension? Because
ForwardDiff.ForwardDiffStaticArraysExt
gives me:
ERROR: UndefVarError: ForwardDiffStaticArraysExt not defined

What are you trying to do, in this case? For users of the packages, as opposed to developers, one doesn’t need to care about the extension modules at all. The public API of the two packages are all that a user should interact with.

Say I wish to use a function from the extension that isn’t exported, is there a way to do that?

I think Base.get_extension should get you the extension module

1 Like

Thank you so much, this is very helpful!

This is very much not recommended.

I understand, but the alternative is to duplicate the function, which already does exactly what I need, in my own code.

With normal modules (not extensions), Julia allows us to use non-exported methods “at your own risk”.

Yeah that’s fine under the understanding that what you’re doing here is very much at your own risk.

1 Like