# Package extension adding new function/variables to package namespace

**URL:** <https://discourse.julialang.org/t/package-extension-adding-new-function-variables-to-package-namespace/122034>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 31, 2024, 9:29am UTC](https://discourse.julialang.org/t/package-extension-adding-new-function-variables-to-package-namespace/122034 "2024-10-31T09:29:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SunnyUser](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sunnyuser/32/206001_2.png) [@SunnyUser](https://discourse.julialang.org/u/SunnyUser)\
**Post date:** [October 31, 2024, 9:29am UTC](https://discourse.julialang.org/t/package-extension-adding-new-function-variables-to-package-namespace/122034/1 "2024-10-31T09:29:19Z")

</div>

Hi all 🙂

Short summary what I want:  
Assume I have package `A` with main module/namespace `A` and a test extension for `A` that means the extension gets only loaded if `Test` is loaded.

Different package `B` imports `A`. In `B`’s test section I want to load `A`’s test extension for a function/variable `f` from `A` defined in `A` test extension - only used for testing. This function/variable `f` should not exist for normal use of `A`. That means if `Test` is not loaded. The function/variable `f` should be in the namespace of `A` directly.

Is there a way to do this and how?  
If not would this a useful feature request?

Cheers

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 31, 2024, 2:13pm UTC](https://discourse.julialang.org/t/package-extension-adding-new-function-variables-to-package-namespace/122034/2 "2024-10-31T14:13:57Z")

</div>

Not really, and I don’t think it is a great behavior if global variables exist or not in packages depending on what other packages are loaded. You can have the variable always existing (initialized to `nothing`) and then set it in the ` __init__ ` of the extension if you want for example.
