https://docs.julialang.org/en/stable/manual/style-guide/#Avoid-type-piracy-1
“Type piracy” refers to the practice of extending or redefining methods in Base or other packages on types that you have not defined.
You’re reaching out of your module and messing with someone else’s. Meaning doesn’t really have any bearing on whether something is doing piracy or not.
What you’re considering here isn’t really piracy at all — it’s what we’ve typically called “puns.” That is, you’re using the same function to do something completely different, hence pun: same word, different meaning. It wasn’t initially obvious that puns would be an impediment to generic programming. There were initially a number of cases built into base that re-used the same function for multiple purposes. The biggest problem with puns is that folks need to be explicitly aware of their function signatures. It breaks duck-typing.
While the documentation for size
doesn’t show it, we have a number of array-like objects that implement size
as you might expect. For example numbers are able to behave like a 0-dimensional array. I’d probably be good to remove the ::AbstractArray
from that definition.