Should we mark some answer as answering this question? The top one saying “yes”, or the one above with “no”…? Or even mine here?
The discussion that followed is interesting (to me), I hope we’re not scaring new users away in “New to Julia” group. I believe the answer is yes, you CAN, define +
, and using that +
alone in your code will always be ok, but seemingly not with sum
(who would use for string
s?). But it doesn’t mean you really should do this for your own code, let alone for packages, i.e. help others do this.
This is interesting, but even more interesting to me would be an operator that seemingly concatenates strings, but doesn’t actually, returns a concat type of prefix and suffix, only lazily doing an actually concatenation, maybe never in practice. If you concat again, you might naively get a tree of that type, but then I think we went to far, and we could only ever have two parts, not doing the concat until we really need it e.g. for a regex, or to call C code that expects the string linear in memory.
I’m still not sure from the discussion, if sum would be a problem… in reality, even is used…