2 ms·
I think this sounds nice but it feels difficult to me. One property you might want would be that, in some sense, parentheses would always remain balanced. I th
by dan-robertson 6y ago
I think this sounds nice but it feels difficult to me.
One property you might want would be that, in some sense, parentheses would always remain balanced. I think this would be very hard if not impossible to get from the graph-of-byte-ranges representation. But I’d be excited if someone figured out how to do it.
I think a particular part of the problem is to get the diff algorithm to match parentheses correctly. Consider some changes from A to B:
1A (a b)
1B (a b) (c d)
2A (define p () (a) (b) (c))
2B (define q () (a) (b) ) (define q () (p) (c))
3A (a b c d)
3B (a b) (c d)
4A (a b c )
4B (a b) (c d)
5A (a b c)
5B (a b) (d)
I think in these examples it’s relatively easy to pair up parentheses in a reasonable way though there are already some tricky cases. As you get more of a tree structure and want a diff algorithm that can think of operations like wrapping, splitting, and spreading as basic operations as well as appending and deleting, I think it becomes even harder to make the right call. Indeed I think computing this kind of diff of s-expressions is computationally a harder search problem than diffing files.