Without dissuading this effort—indeed, I'd love if this is improved—I'll note some cases where
if let foo = foo has effects beyond simply making
self.foo; if we're in a mutating method or a class method,
self.foocould change within the body of the
foostays the same
foois a global variable (or type-level variable in a type-level method); the same could happen
foois a captured
var; the same could happen if
foois also captured in another closure. (This one's pretty rare.)
foois a local
if let, this shadows the local
foo, making it unassignable within the body.
One answer is to say that the shorthand will not allow any of these; it will only work when
foo is already immutable (i.e. declared with
let or as a function parameter). I think that's perfectly valid, at least for the first version of a proposal, since it's possible to open up later. I just want to make sure it gets mentioned.