Is dispatch on another type's parameter (::NotMyType{MyType}) piracy?

Broken for Author B, but not for Author A, who doesn’t have ownership of nor responsibility for MyType. Any other parameterized NotMyType{T} will do what Author A expects.

Some Author C using both packages might discover the inconsistent behavior, if so it’s more Author B’s problem to fix, should he or she want to. Regardless, this isn’t type piracy, which has a clear definition which this scenario doesn’t meet.

That’s what I mean by a general rule for your scenario being impossible, for the record. Obtaining perfect harmony for everyone’s code is a laudable goal, but there’s no rubric which can make that happen in every general case. Like it’s good if every method of a given function does “the same thing”, defining push!(t::MyType, a) to instead delete a wouldn’t be neighborly, but there’s no good way to define what’s in or out of bounds here. Base methods of push! don’t have side effects, is it ok if user methods do? Just gotta use your best judgement.

2 Likes