Swift

Musings related to the Swift programming language


Swift Lookbehinds via Reverse Matching Part 2
Jul 10, 2024 • 86 minute(s)

Part 1 Had a video call with Michael and was able to figure out what I need to do. I was actually pretty spot on with what reverse matching is supposed to be (I mean the name kind of says it all), but what I inferred from his suggestion is that my approach is inefficient. Instead of performing a reversing operation on the entire AST, his suggestion was to implement reverse variants of the following instructions: matchScalar, matchBitset, matchBuiltin, matchAnyNonNewline, and advance.

Continue reading ...
Swift @ WWDC 2024
Jun 14, 2024 • 7 minute(s)

Another year, another WWDC. Here are my notes on improvements to the Swift language from watching the various keynotes and sessions.

Continue reading ...
Swift Lookbehinds via reverse matching
Jun 12, 2024 • 2 minute(s)

A month or two ago I discovered that Swift’s fancy new regex builder and regex literals didn’t support lookbehinds, a feature I wanted for a project I’m working on. I decided to see what it would take to implement it myself and slowly worked my way to a (sort-of) (mostly) working initial implementation. Michael Ilseman (one of the original authors of the Swift 5. 7 regex work) has been kindly giving me pointers that were essential for getting as far as I have. In his eyes, the core concept behind lookbehinds, is reverse matching. This is the focus of this scratchpad.

Continue reading ...