[Pitch #2] Regex Literals

I feel strongly we need to let go of the idea that we will be able to support the bare /regex/ syntax. While it is certainly a well known precedent for the spelling of a regex literal, it was always a bad precedent and I don't recommend Swift pursues the sort of lexical cartwheels and recourse to heuristics blurring the line between lexical and Semantic analysis these languages have to resort to. Regex literals are a very rich and arbitrary combination characters and a single character delimiter is always going to be too flimsy for cases that come up sufficiently frequently to make the extended #/regex/# syntax necessary anyway.

All this aside the solution proposed for some of these problems, that of deprecating using / as a prefix operator is going to source break a innovative and significant open source project The Composable Architecture and a good deal of client source that uses it. In the end, they got there first and clinging to having the bare '/regex/' syntax available simply can't be justified for a much more niche requirement such as regex literals, particularly in the face of the almost as recognisable syntax #/regex/# being proposed anyway which would avoid all this disruption.

I'm sure however if a way could be found to include \ in the characters that can be used to define operators the TCA folk would be only too happy.

9 Likes