SE-0345: `if let` shorthand for shadowing an existing optional variable

I'm slowly gravitating towards this and coming to a conclusion that this is superior to the "if let" shortcut being discussed on the following fronts:

  • handles situation more generally, including cases outside of if / guard
  • makes shadowing intent explicit (prohibits the current implicit shadowing "let x = x" in all contexts).
  • prohibits repeating the same name (shadowing let someName = someName) thus freeing user's brainpower from parsing the string and checking if the two names match or don't match.
  • as a result makes homograph spoofing more obvious (a minor bonus point)

I appreciate that the cost of adding a new keyword is high, but in this case I'd consider doing this.

With that reasoning in mind I sadly have to change my +1 to -1 for the proposal being discussed.

1 Like