# \[ANN\] InlineExports.jl

**URL:** <https://discourse.julialang.org/t/ann-inlineexports-jl/21466>\
**Category:** Package Announcements\
**Created:** [March 4, 2019, 4:05pm UTC](https://discourse.julialang.org/t/ann-inlineexports-jl/21466 "2019-03-04T16:05:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evey/32/214967_2.png) [@Evey](https://discourse.julialang.org/u/Evey)\
**Post date:** [March 4, 2019, 4:05pm UTC](https://discourse.julialang.org/t/ann-inlineexports-jl/21466/1 "2019-03-04T16:05:40Z")

</div>

I would like to announce a tiny package called [InlineExports.jl](https://github.com/dalum/InlineExports.jl). It provides a single macro, `@export`, which allows you to export variables, functions and types at their points of definition. This is best illustrated by an example:

```julia
module M
using InlineExports

@export function f(x)
    return x^2
end

@export const answer = 42
@export my_string = "Banana"

end

```

Any comments or feedback is much appreciated!

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [March 4, 2019, 4:24pm UTC](https://discourse.julialang.org/t/ann-inlineexports-jl/21466/2 "2019-03-04T16:24:59Z")

</div>

FWIW I rather like seeing the list of exports at the top of a package rather than being interleaved with the function/value definitions. I know in an ideal world that info would be easily accessible in the docs, but often it ends up being easier to glance at the top-level `src/SomePackage.jl` file to see what’s exported.

Others may have diverging opinions, of course.

---

<div class="post-metadata">

**Author:** ![Evey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evey/32/214967_2.png) [@Evey](https://discourse.julialang.org/u/Evey)\
**Post date:** [March 4, 2019, 4:29pm UTC](https://discourse.julialang.org/t/ann-inlineexports-jl/21466/3 "2019-03-04T16:29:41Z")

</div>

I agree wholeheartedly for most packages! 😊 But when working on private projects or during development, I have found myself putting `export` statements above function definitions, etc. where, in a lot of cases, inline exports actually made more sense. There was some discussion about this in: [export keyword in front of functions / types · Issue #8005 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/8005)

Edit: And if you want a list of exported names, there is also `Base.names(::Module)`.

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [March 4, 2019, 6:22pm UTC](https://discourse.julialang.org/t/ann-inlineexports-jl/21466/4 "2019-03-04T18:22:45Z")

</div>

Makes sense. And sorry for starting out with criticism right out of the gate. It’s a cool package - the way you used `Symbol` to create a macro with a reserved word as a name is pretty clever.

Also thanks for the pointer to `Base.names`, that seems useful.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 4, 2019, 6:51pm UTC](https://discourse.julialang.org/t/ann-inlineexports-jl/21466/5 "2019-03-04T18:51:39Z")

</div>

> [@ssfrr](#):
>
> list of exports at the top of a package

This is a violation of [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself), as you need to write the exported symbol one extra time. For packages which span many files, keeping this consistent requires some effort, which `InlineExports.@export` makes unnecessary, so I will be very happy to use it.

Also, note that some packages don’t export the API — this is also a valid style for Julia.

---

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [March 5, 2019, 5:17am UTC](https://discourse.julialang.org/t/ann-inlineexports-jl/21466/6 "2019-03-05T05:17:04Z")

</div>

Whether this package is useful depends, on the use case.  
Some interops would be placed at several distinct modules for the sake of better code organizationm, and `InlineExports.jl` could be useful when it comes to export something from an internal module to another(also internal).  
Also, the top-level module that describes which APIs to be exported to users, would better not to use `@export`.
