# Is it possible in Julia?: Support a limited type inference version in order to decide whether a function is defined or not

**URL:** <https://discourse.julialang.org/t/is-it-possible-in-julia-support-a-limited-type-inference-version-in-order-to-decide-whether-a-function-is-defined-or-not/45509>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 25, 2020, 3:38pm UTC](https://discourse.julialang.org/t/is-it-possible-in-julia-support-a-limited-type-inference-version-in-order-to-decide-whether-a-function-is-defined-or-not/45509 "2020-08-25T15:38:12Z")\
**Posts on this page:** 1\
**Page:** 2

<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:** [August 27, 2020, 8:33am UTC](https://discourse.julialang.org/t/is-it-possible-in-julia-support-a-limited-type-inference-version-in-order-to-decide-whether-a-function-is-defined-or-not/45509/21 "2020-08-27T08:33:28Z")

</div>

> [@schlichtanders](#):
>
> No longer the need for forcing everyone to define `IteratorSize` if you actually only want to check whether `length` or `size` are defined.

But traits _are_ solution to that problem that just work fine already — framing this as “forcing” is a bit of a stretch.

FWIW, for the reasons discussed in this topic, I don’t think that conditioning code paths on whether they _would_ error is a solution that meshes well with how Julia works (and I don’t know about any language that would support this well). Effectively you want to use errors for control flow, which is already a code smell, _and_ rely on the compiler to predict them, which it is not designed for (not all errors are “type stable” in the sense that the method signature is enough to predict them).

Also, from a practical perspective, `MethodError`s can happen down the line even when a particular function was _intended_ to be defined, but there is a bug in the code (it is probably in the top 5 for trivial coding mistakes).

[Previous page](https://discourse.julialang.org/t/is-it-possible-in-julia-support-a-limited-type-inference-version-in-order-to-decide-whether-a-function-is-defined-or-not/45509.md?page=1)
