Sukera
October 13, 2023, 4:49pm
30
Since noone seems to have linked it so far, there’s also this explanation by @StefanKarpinski (though with a slight Rust bend, as that was the original question there):
In a sense we do:
If we look at our table of variances, we see that &mut T is invariant over T . As it turns out, this completely fixes the issue!
Since all types in Julia behave like &mut T in Rust (or at least there’s no way of expressing anything else in the type system—there are immutable types and reference types but they are all treated uniformly), that fact translated to Julia would imply that all parametric types are invariant, which is precisely what we do. In order to do somet…