SE-0230: Flatten nested optionals resulting from `try?`

I honestly still don't know what to think about this proposal, despite participating in the discussion thread and thinking about it extensively. On the one hand, this makes the behaviour of try? significantly more complicated (as seen several times in this very review thread) and I would generally prefer simpler rules with a little more boilerplate. On the other hand, the behaviour of all these other related language features (e.g. as?) is already similarly complicated and hard to internalise (again, as seen in this review thread), so perhaps making try? slightly more ergonomic in some cases is worthwhile.

To summarise my thinking, the downsides of making this change are breaking source compatibility and complicating the behaviour of try?. The upsides are improving consistency with other related features and avoiding the double optional, which can be surprising and require some extra code to unwrap. I will note that the analysis of the source compatibility suite for source-breaks also double as a rough benefit analysis for this change, and the result is that it possibly helps in about 1-2% of try? uses.

1 Like