vctrs icon indicating copy to clipboard operation
vctrs copied to clipboard

Generic diff?

Open gaborcsardi opened this issue 2 years ago • 0 comments

Like the Unix command line diff, not base::diff().

I added some diff functions to cli, that are internally completely generic, and I think they would work great for vctrs: https://github.com/r-lib/cli/blob/master/R/diff.R https://github.com/r-lib/cli/blob/master/src/diff.c

To implement diff for a new type, you only need to supply a function that compares if two instances of the type are equal or not (_cmp_chr() in the C code). You'd also need some format/print methods if you want to print the result nicely.

Otherwise the C code for calculating the edit operations and the R code for calculating chunks from the edit operations are completely generic.

I can submit a PR that implements the low level stuff if you are interested.

gaborcsardi avatar Oct 08 '21 11:10 gaborcsardi