# Strict typing and restricting types in a method's signature

**URL:** <https://discourse.julialang.org/t/strict-typing-and-restricting-types-in-a-methods-signature/645>\
**Category:** General Usage\
**Created:** [November 29, 2016, 3:21pm UTC](https://discourse.julialang.org/t/strict-typing-and-restricting-types-in-a-methods-signature/645 "2016-11-29T15:21:54Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![bpr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bpr/32/2710_2.png) [@bpr](https://discourse.julialang.org/u/bpr)\
**Post date:** [November 29, 2016, 7:38pm UTC](https://discourse.julialang.org/t/strict-typing-and-restricting-types-in-a-methods-signature/645/9 "2016-11-29T19:38:01Z")

</div>

> [@Meaning of {T}](https://discourse.julialang.org/t/meaning-of-t/623/5):
>
> Strict typing of functions is kind of a new user trap for this reason: it’s just for throwing errors, but has a feel that it might improve performance.

I disagree. It’s not **just** for throwing errors, but like types in general it serve as useful, compiler checked documentation.

I don’t want to reopen the age old static vs dynamic typing debate. I’m a proponent of the former, and while Julia is dynamically typed, it allows me to write code in a mostly statically typed style. Many Julia programmers, like Lispers, seem to think of types only as useful for optimization, but I’d put types in many places even if it made the code a bit slower. IME your unintended uses for loose typing end up being unintended consequences.

> [@Meaning of {T}](https://discourse.julialang.org/t/meaning-of-t/623/5):
>
> That’s why there’s the mantra: strictly type your types, loosely type your functions.

I prefer to strictly type function arguments and return types. Not a categorical rule, but a general preference. I may leave local variables untyped if their type appears obvious. YMMV, and it obviously does.

---

_[View the full topic](https://discourse.julialang.org/t/strict-typing-and-restricting-types-in-a-methods-signature/645)._
