Elektrine lite

← Feed

@sminez@hachyderm.io

Post #2280771

2025-10-30 09:51 UTC

@jbert@hachyderm.io not nonsense at all! The problem is when you have parallel actions that would trigger on the output produced by one another. This is the simplest example of the problem: , { x/Alice/ c/Bob/; x/Bob/ c/Alice/; } "Replace all occurrences of "Alice" with "Bob", replace all occurrences of "Bob" with "Alice". You need to know which "Bob"s are from the original input and which came from being replacing an "Alice", otherwise everything will end up as "Bob". You can get around this by interleaving the execution of each branch but the combinatorics of that quickly get fiddly if you have compound expressions. Breaking things into two passes (locate all matches, apply actions) ends up being a lot easier.

Replies (1)

  • @sminez@hachyderm.io 2025-10-30 09:58

    @jbert@hachyderm.io I haven't tried implementing it yet, but I suspect that you could handle this by running parallel groups in a similar way to how traditional regex engines handle alternations: so each group is running the underlying regex search for the next match in parallel and whichever matches first is run, and since overlapping matches are disallowed we know that we start the next search from the end of whatever we just matched. Given that the initial implementation of this (both in Sam and my own use case in ad) is for a text editor where we know we have the full (finite) input, its a lot simpler to handle things in two passes.

    Open ##2280772