Type II piracy is commonly known as type piracy by the Julia developer community. It refers to the situation where a third-party function is extended without using the programmer's own types in any of the function arguments. It usually happens when you want to extend the third-party package by injecting your own code. Let's go through a hypothetical example.
Suppose that you want to mimic the same behavior in JavaScript of adding a string and a number together, where the values concatenate as if they are both strings:
To make it happen in Julia, we would be tempted to do the following in MyModule:
module MyModule
import Base.+
(+)(s::AbstractString, n::Number) = "$s$n"
end
We can paste the preceding code in the REPL and do a quick test:
This seems to be working great! But there are some hidden issues with this approach. Let's look at why it is still a bad idea.