# How can I declare a function in a module for the sole purpose of being extended by users?

**URL:** <https://discourse.julialang.org/t/how-can-i-declare-a-function-in-a-module-for-the-sole-purpose-of-being-extended-by-users/91661>\
**Category:** General Usage\
**Created:** [December 15, 2022, 12:05am UTC](https://discourse.julialang.org/t/how-can-i-declare-a-function-in-a-module-for-the-sole-purpose-of-being-extended-by-users/91661 "2022-12-15T00:05:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [December 15, 2022, 12:05am UTC](https://discourse.julialang.org/t/how-can-i-declare-a-function-in-a-module-for-the-sole-purpose-of-being-extended-by-users/91661/1 "2022-12-15T00:05:10Z")

</div>

Suppose I have such a module

```julia
module Foo

abstract type Bar end

function do_something(bar::Bar)
    bar_prepared = prepare(bar)
    "do something"
end

end

```

My intention for the user is that the user will define a concrete type that is a subtype of `Bar` and define a function `prepare` on that concrete type. Then they can call `do_something` in my module.

Right now, I declare the function by define a dummy function

```julia
function prepare()
    return nothing
end

```

but I am not happy with this. What would be your suggestion?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 15, 2022, 12:07am UTC](https://discourse.julialang.org/t/how-can-i-declare-a-function-in-a-module-for-the-sole-purpose-of-being-extended-by-users/91661/2 "2022-12-15T00:07:33Z")

</div>

Define a 0-method function and document how it should be used:

```julia
"""
The function `do_something` is supposed to be extended by users in the following way....
"""
function do_something end

```
