Quoting Patrick Smith (2018-10-16 18:32:48)
> The union function could verify that the two adaptors are the same,
> using the == operator, and panic if not. However, this breaks down if
> the adaptors, instead of being defined as struct{}, are defined as
> types which don't support ==.
This works, provided you use the interface approach in most of your
examples. It would be ideal to catch the error at compile time though.
> This could even be construed as a feature. The union function takes two
> sets, possibly with different adaptors, and merges their contents into
> a new set using an adaptor passed as a parameter to union, and which
> could be different from the adaptors for both input sets.
True, although for some cases you really do want to require both
arguments to have the same adaptor. In a persistent set or map based on
persistent trees[1], you can get asymptotic speedups on merge/union
if you can assume the adaptor is the same.
[1]: https://en.wikipedia.org/wiki/Persistent_data_structure#Trees
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.