go-cmp icon indicating copy to clipboard operation
go-cmp copied to clipboard

Merge cmpopts and cmp package?

Open zombiezen opened this issue 5 years ago • 3 comments

As a semi-frequent user of the cmp package, most of the time I pull up godoc.org reference is to figure out whether a particular useful option is in cmpopts or the cmp package. Genuinely curious: is there a meaningful end-user benefit to keeping these packages separate? I seldom use cmp without cmpopts, and I suspect this is common.

/cc @dsnet

zombiezen avatar Apr 17 '19 21:04 zombiezen

The original intention was to design a comparison library that was highly extensible with a small number of options.

Implementing cmpopts as a separate package kept the implementation of cmp honest such that cmpopts does not rely on internal details of cmp. In other words, cmpopts is forced to be entirely implementable in terms of the first-class options provided by cmp. This was done in reaction to other comparison libraries I looked at that supported many options and each option deeply touched internal details of the overall comparison logic.

That said, from a end-user perspective, I can see how the two being in the same package can be convenient. At this point in time, it's a bit awkward to merge cmpopts into cmp since there would now be two ways to get at the cmpopts functionality.

dsnet avatar Apr 17 '19 21:04 dsnet

At this point in time, it's a bit awkward to merge cmpopts into cmp since there would now be two ways to get at the cmpopts functionality.

Presumably everything in cmpopts would be replaced with a forward to the corresponding symbol in cmp, and marked as deprecated.

I think the separation makes a lot of sense from the perspective of the implementation, but it's pretty confusing as a user. Even as a user with an above-average understanding of cmp's internals.

neild avatar Apr 17 '19 21:04 neild

I came here to ask the same question as @zombiezen. I just want to point out that the cmpopts package isn't prominently visible from the cmp documentation, so as a user I spent a bit of time to find what I was looking for, and couldn't in the cmp package alone. When I eventually discovered the cmpopts package I found what I needed.

So I would also encourage merging the two packages to make the documentation easier to use.

meling avatar Jul 24 '20 22:07 meling