But avoiding source breaks is important Doug and even one of the proposal authors conceded this was a showstopper during the pitch phase.
For me the strategy of managing the transition using feature flags is worse than the original problem, breaking the idea that Swift syntax is a linear progression forward. Far better not to create the problem in the first place no?
The "necessity" for the source break arises directly from fact the bare /regex/
syntax is the wrong destination. This, is in turn is a consequence of the naïve view in my opinion it will ever be possible to contain a full range of possible regexes inside single character delimiters let alone one which is already an operator in Swift. It's as futile as trying to construct the enclosure for a tiger with secondhand chicken wire and as unlikely to end well. The result is weird escaping rules and whitespace sensitivity that needs to be documented and the occasional mis-parses that have already been mentioned.
You need a distinct introducer that is not currently part of the language, for example #/
to switch the lexer into regex tokenising mode and a distinct terminator /#
to cater for elements that may come up inside the regex. The #/regex/# syntax is no great beauty but fits this requirement well and also borrows from raw strings the notion that while it is essentially a string \
escapes are passed through.