If you have ever used @code_warntype you know that whether a function is type-stable isn’t always as obvious as it first appears. The larger reason to allow type instability is that Julia doesn’t really have pointers (well, it has them, but their intended use is only for interacting with C or some special array handling). The issue with this is as follows: suppose you have two types Pion <: Meson and Kaon <: Meson and you want a function that returns a Meson. In C++, this can be achieved by returning a Meson pointer. The equivalent behavior in Julia is to return a reference of type T <: Meson. If Julia were to fully enforce type stability, functions would be required to return a specific Meson. So, it goes a bit beyond whether Julia is “easy”.
1 Like