# 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:** 42

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [August 28, 2025, 9:33am UTC](https://discourse.julialang.org/t/the-strangeness-or-not-of-as-string-concatenation/131943/42 "2025-08-28T09:33:25Z")

</div>

> [@StefanKarpinski](#):
>
> There’s also always the option of having a non-standard string type for paths, e.g. `path"foo/$part/bar.txt"` which could normalize to the right kind of path and do checks like if `part` is something like `/` or `/root` then raise an error.

I imagine you may well be thinking of the (dormant, but not forgotten/abandoned) thread [Designing a Paths Julep](https://discourse.julialang.org/t/designing-a-paths-julep/124335), but in case you or any interested readers have forgotten, that’s exactly what I’m proposing there 🙂

Another upside of this sort of approach is that based on whether a `$string` or `$path` is being interpolated, you can catch and handle unsafe input like:

```julia-auto
# from reading config/user input/etc.
untrusted_file = "../../../../../../etc/passwd"
read_path = path"user_content/$untrusted_file"
                            # ^ interpolation error thrown

```

> [@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/52):
>
> In practice, people didn’t have a problem with a symbol `+` used for a commutative operation (addition) also being used for a non-commutative operation (concatenation) when the input types can differentiate the call.

Eh, IEEE floats may muddy the waters, but **`+`** is _the_ Abelian group operator. Just because it’s not perfectly adhered to is no reason to abandon convention.

That said, I do see the confusion around `*`, and I think there’s a solid argument that instead of picking between punning addition/multiplication it would be sensible to dedicate an operator to the concatenation of containery-types (vectors, strings, etc.) like `++`. Until Julia 2.0 though, we’ll just have to live with the status quo, and this niggle is fairly low my list of breaking changes I wish we could make.

---

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