# Is it OK to structure my packages like this (benign type piracy)?

**URL:** <https://discourse.julialang.org/t/is-it-ok-to-structure-my-packages-like-this-benign-type-piracy/126627>\
**Category:** General Usage\
**Tags:** package, packages, design, type-piracy\
**Created:** [March 6, 2025, 11:24am UTC](https://discourse.julialang.org/t/is-it-ok-to-structure-my-packages-like-this-benign-type-piracy/126627 "2025-03-06T11:24:39Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [March 6, 2025, 12:09pm UTC](https://discourse.julialang.org/t/is-it-ok-to-structure-my-packages-like-this-benign-type-piracy/126627/3 "2025-03-06T12:09:35Z")

</div>

Type piracy means [defining methods on functions you don’t own for arguments whose types you don’t own](https://discourse.julialang.org/t/why-hasnt-linearalgebra-been-removed-from-the-default-sysimage/126395/12).

I would consider “you” to actually mean “you”/“your organization”, not necessarily “your particular package”. So, if you own `PackageA` and `PackageB`, then what you’re proposing should be okay (although it may not be the best design). This is probably a pretty common pattern between a user-facing package and a “base” package.

I would point out that

> ```julia
> """
> a::Function
> 
> Only add methods if you're `PackageB`!
> """
> 
> ```

isn’t right: _Anyone_ can and should add methods to `a` as long as they own any of the types of the arguments they want to pass to `a`. But you probably just mean “don’t add methods here”.

If you don’t “own” both `PackageA` and `PackageB`, then this approach is type piracy, and you should absolutely not do it. In particular, if `PackageA` and `PackageB` are not tightly coupled and coordinated, then it is the responsibility of `PackageA` to define methods for `a` for any `Base` types, or any types defined in `PackageA`.

---

_[View the full topic](https://discourse.julialang.org/t/is-it-ok-to-structure-my-packages-like-this-benign-type-piracy/126627)._
