# How to exactly lock the type of the arguments of a function?

**URL:** <https://discourse.julialang.org/t/how-to-exactly-lock-the-type-of-the-arguments-of-a-function/66325>\
**Category:** General Usage\
**Created:** [August 13, 2021, 6:25am UTC](https://discourse.julialang.org/t/how-to-exactly-lock-the-type-of-the-arguments-of-a-function/66325 "2021-08-13T06:25:56Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [August 13, 2021, 8:54am UTC](https://discourse.julialang.org/t/how-to-exactly-lock-the-type-of-the-arguments-of-a-function/66325/10 "2021-08-13T08:54:26Z")

</div>

Well, it won’t hurt to read the manual, at least the parts related to the argument passing conventions, type system, dispatch, handling of the arrays, numerical computing, performance tips and style guide. That may eliminate a large fraction of questions to begin with. It’s not a huge read, should take maybe a day or two.

Now, if you need to restrict the dimensions, the best way is to use [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) package. It provides array types with sizes encoded in signature. Using them must also improve performance as the standard arrays aren’t optimized for small sizes (see also [this topic](https://discourse.julialang.org/t/common-allocation-mistakes/66127)).

Style-wise, `return nothing` isn’t very Julian. If you look at the standard library functions, very small fraction of them uses `nothing` as the return value, even those with the main purpose of mutation (e.g. `push!` or `copy!` or `sort!`) return something return something that can be immediately used. In your case, `return beta` is the obvious choice.

Regarding a confusion from defining multiple methods and getting (or not getting) errors because the call dispatched to a stale (from your viewpoint) method. Consider [Pluto.jl](https://github.com/fonsp/Pluto.jl) for prototyping. It is designed around the idea that there must not be any hidden state beside what is visible in the notebook (i.e. if you delete a method, it automagically starts a fresh process where that method is not defined). Or use [Revise.jl](https://github.com/timholy/Revise.jl) which also keeps method tables consistent with what’s written in your source files.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-exactly-lock-the-type-of-the-arguments-of-a-function/66325)._
