# The strangeness (or not) of \* as string concatenation

**URL:** <https://discourse.julialang.org/t/the-strangeness-or-not-of-as-string-concatenation/131943>\
**Category:** General Usage\
**Created:** [August 26, 2025, 2:14pm UTC](https://discourse.julialang.org/t/the-strangeness-or-not-of-as-string-concatenation/131943 "2025-08-26T14:14:07Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [August 27, 2025, 12:10pm UTC](https://discourse.julialang.org/t/the-strangeness-or-not-of-as-string-concatenation/131943/19 "2025-08-27T12:10:34Z")

</div>

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.

> [@Is it possible to define '+' operator for string as '\*' do for them?](https://discourse.julialang.org/t/is-it-possible-to-define-operator-for-string-as-do-for-them/131835/27):
>
> So I think `*` is fine (albeit unusual), but I’d be also happy with `++` or [`append(...)`](https://github.com/JuliaLang/julia/issues/53040) which could be implemented by any sequence type, such as `Vector`s.

> [@Is it possible to define '+' operator for string as '\*' do for them?](https://discourse.julialang.org/t/is-it-possible-to-define-operator-for-string-as-do-for-them/131835/12):
>
> Take also a look [at this thread](https://discourse.julialang.org/t/introduce-as-the-concatenation-operator/37418/61) and the tiny Julia package [PlusPlus.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/PlusPlus) with just three lines of code.

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.

> [@mbauman](#):
>
> Honestly I didn’t get how troublesome `+` would be for strings in Julia until recently … But if we used `+` then folks could (and I’d wager would) end up writing `sum(strs)` (or more straightforwardly `reduce(+, strs)`) to do this. And that _might_ jumble up the orderings!

I’m still not sure from the discussion, if sum would be a problem… in reality, even is used…

---

_[View the full topic](https://discourse.julialang.org/t/the-strangeness-or-not-of-as-string-concatenation/131943)._
