# Using multiple dispatch in packages

**URL:** <https://discourse.julialang.org/t/using-multiple-dispatch-in-packages/16658>\
**Category:** General Usage\
**Created:** [October 22, 2018, 11:45pm UTC](https://discourse.julialang.org/t/using-multiple-dispatch-in-packages/16658 "2018-10-22T23:45:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [October 22, 2018, 11:45pm UTC](https://discourse.julialang.org/t/using-multiple-dispatch-in-packages/16658/1 "2018-10-22T23:45:54Z")

</div>

I need some clarification on how multiple dispatch (or “inheritance”) is working between packages. Let’s take `CSVFiles` for example.

I can run `load("file.csv")` and it returns a table. In the source code, we have `export load, save` yet I don’t see the `load` function defined anywhere. There are

```julia
function fileio_load(f::FileIO.File{FileIO.format"CSV"}, delim=','; args...)
    return CSVFile(f.filename, delim, args)
end

function fileio_load(f::FileIO.File{FileIO.format"TSV"}, delim='\t'; args...)
    return CSVFile(f.filename, delim, args)
end

```

and  
`function _loaddata(file)` which i suppose is a helper function.

The homepage of CSVFiles says something about `FileIO`. I suspect the `load()` is defined somewhere in there… so what is the exact sequence of functions that are run when I type in `load`.

**Moreover** , suppose I am developing a package that can read a particular file and would also like to use `load()` in my package. Can I just have a signature `load(::MyType)`? Will this automatically “hook” into `FileIO`?

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 23, 2018, 1:32am UTC](https://discourse.julialang.org/t/using-multiple-dispatch-in-packages/16658/2 "2018-10-23T01:32:41Z")

</div>

`load` is defined in [FileIO](https://github.com/JuliaIO/FileIO.jl). It’s one of the stranger examples of multiple dispatch, because we explicitly urge people _not_ to extend this function, instead having FileIO call the module-specific version by scoping (e.g., `CSV.load(args...)`), so that the only methods defined for `load` are in FileIO itself and `CSV.load` is a nominally-unrelated function.

This is not how it typically works (in FileIO it seems necessary to allow multiple packages to implement different approaches for a single file format), so I’m not sure this is the best model for understanding how this typically works.
