# \[ANN\] CallableModules.jl – Make Julia modules callable

**URL:** <https://discourse.julialang.org/t/ann-callablemodules-jl-make-julia-modules-callable/136341>\
**Category:** Package Announcements\
**Created:** [March 23, 2026, 11:58am UTC](https://discourse.julialang.org/t/ann-callablemodules-jl-make-julia-modules-callable/136341 "2026-03-23T11:58:55Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [March 23, 2026, 1:58pm UTC](https://discourse.julialang.org/t/ann-callablemodules-jl-make-julia-modules-callable/136341/5 "2026-03-23T13:58:49Z")

</div>

```julia-auto
# This is type piracy, but is fully generic. If every package which wants to have its
# module callable uses this package, no problems with multiple definitions should occur.
(x::Module)(varargs...; kwargs...) = Val(x)(varargs...; kwargs...)

```

> [@PatrickHaecker](#):
>
> - If Core implemented the relevant method, it would no longer be type piracy…
> - …
> - The package’s purpose is exactly to avoid type piracy problems by being the coordinating instance.

Nope, not only is it unconditionally type piracy, all packages `using CallableModules` would interfere with the potential `Core`/`Base` implementation and likely break something. This gets worse if `CallableModules` gets versions that aren’t strictly aligned with Julia versions. These sorts of piracy packages are tolerable as personal `Base` hacks, but not as widespread dependencies.

Secondly, this does not work as stated.

1. Apps are documented to require the macro call `@main`, which resolves to a function name `main` after some background registration for Apps and automatic `Main.main` calls. `@module_main` does not do any of that and explicitly supports names other than `main`.
2. The premise that the shell command and the underlying module share a name is false. The [documented Apps examples](https://pkgdocs.julialang.org/v1/apps/#Creating-a-Julia-app) ALL specify names in the `[apps]` section of `Project.toml` that differ from the names of the package or submodules. Multiple App commands can be based on 1 module by configuring [default command-line flags](https://pkgdocs.julialang.org/v1/apps/#Configuring-Julia-Flags) for the Julia process; in the general case, a command can specify much more than a Julia module. The `-m` flag of the `julia` command for running a package’s `@main` does demand the package’s name, but that obviously compromises the visual parallel to a callable module.

I really don’t understand why you claim this package has anything to do with Apps or shell commands when it already does exactly what it’s named: make modules callable by forwarding to an annotated function. If the intent was to justify calling the module `MyMod(args...)` instead of a documented function `MyMod.main(args...)` or even an exported alias `const approxappname = main` among others, then you’ll need to figure something else out that doesn’t misinform.

---

_[View the full topic](https://discourse.julialang.org/t/ann-callablemodules-jl-make-julia-modules-callable/136341)._
