-
Notifications
You must be signed in to change notification settings - Fork 9
simplifies the creation of "diff generators" outside the library #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
First off, thanks for working on making this library useful. This code was a one-off thing written for experimental purposes and I'm glad you're using it and pushing to make it better. I have two main concerns:
|
Hmm, I can not understand with this point of view why my code as not well as your. But perhaps just need to replace print-object on something like render-diff and render-diff-window?
Indeed, "snake" is not a common term for all existing LCS algorithms. I can offer is this:
And instead (in compute-lcs):
use
Or simple:
|
I've been thinking for some time, and reworked the code. Your comments? |
This is getting complicated enough that it should be split into two commits, one to manage the printing changes, and one to manage the snake changes. Could you do that, please? I think the changes for printing make sense, and will pull those once you've split them out. As for the snake changes, I think a better way to go would be to make something like GENERATE-DIFF part of the public API, but instead returning the result of CONVERT-LCS-TO-DIFF. That way the snake bits stay private (the particular algorithm for least common susbsequences shouldn't be exposed, IMHO, just the diffing bits). I note that you are already exporting all the diff-related accessors and so forth, so I think that takes care of the needs of diff generators. Do you agree? |
I'm too busy now, I'll do this through a few days. |
I split my changes on two commit. generate-diff has the following problem: diff-generator is designed to create classic "by line" diff. But for a wiki engine I need also "by word" diff. I can independently make it on base compute-lcs call. Other variants - to allocate compute-lcs in a separate library so that I could use it directly or try to develop a universal "diff-by-word-generator". In my opinion the easiest way to allow users to use compute-lcs. |
I don't understand why using COMPUTE-LCS directly is any better than using the result of CONVERT-LCS-TO-DIFF and/or why the information in COMPUTE-LCS is better for by-word diffing. (I can see how you might not want to use diff windows for by-word diffing, but the MODIFIED-DIFF-REGION and COMMON-DIFF-REGION are quite different.) AFAICS, they provide exactly the same information, but in different formats. Anyway, the changes to use COMMON-SEQUENCE don't seem quite right. Just construct COMMON-SEQUENCE objects directly from the snakes in COMPUTE-LCS and leave the snakes alone; don't try to be clever and minimize allocations. That way, COMMON-SEQUENCE is obviously an external interface, rather than some implementation detail. |
I guess I just missed it. Now I have a lot of different problems, so I it's hard to go into details. I look at it again. |
You were quite right, so even easier. I added function # 'compute-rad-diff and exported needed symbols. |
simplifies the creation of "diff generators" outside the library
Looks good, thanks very much! |
I exported some symbols and removed a few generic functions (they are not
needed and only complicate things). This is nessesary for me to write own
"diff generator" for wiki pages. You can view my generator in the work here:
http://cliki2.lisper.ru/history/CLiki/3369769658-3488841891,
the source code here: https://github.com/archimag/cliki2/blob/master/src/diff.lisp .