Pre-RFC: Allow passing uninitialized values to functions

@Ericson2314's unduly neglected Stateful MIR proposal seems highly relevant here.

Personally (this is the naming scheme I was advocating since before 1.0):

  • &move for owned references you can move out of. Intuitively: & (a read-only reference) -> &mut (a reference you can mutate) -> &move (a reference you can move out of), in order of increasing capability.

  • &out for references that refer to an uninitialized value and need to be initialized, by analogy with precisely the "out parameters" of C# and D referenced above.

But I think mahkoh at some point also used the same in/out naming as canndrew (or did they have &own?), and IIRC gereeter used &uninit for what I'm referring to as &out, and canndrew as &in, so more or less every possible name has been used for every possible concept by this point, which is presumably our penance for having tried to build the tower of Babel.

Coming back down to Earth, I don't think e.g. &out would be backwards compatible: I've literally seen code with &out in it, being a shared reference to a variable named out. Presumably the same thing hypothetically applies to &uninit as well.

1 Like