# Make contains infix

**URL:** <https://discourse.julialang.org/t/make-contains-infix/4644>\
**Category:** Internals & Design\
**Tags:** proposal, infix\
**Created:** [July 4, 2017, 3:10pm UTC](https://discourse.julialang.org/t/make-contains-infix/4644 "2017-07-04T15:10:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 4, 2017, 3:10pm UTC](https://discourse.julialang.org/t/make-contains-infix/4644/1 "2017-07-04T15:10:52Z")

</div>

why not make `contains` infix?

---

<div class="post-metadata">

**Author:** ![ararslan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ararslan/32/3825_2.png) [@ararslan](https://discourse.julialang.org/u/ararslan)\
**Post date:** [July 4, 2017, 6:28pm UTC](https://discourse.julialang.org/t/make-contains-infix/4644/2 "2017-07-04T18:28:33Z")

</div>

There are a few problems with making arbitrary functions infix. The first is “where do you stop?” That is, which functions become blessed to be infix and which don’t make the cut? The second is the question of parsing precedence. The precedence of `in`, for example, is quite clear, but it becomes unclear for arbitrary functions.

The convention thus far has been to keep ASCII functions/operators as prefix (of course with the exception of the standard mathematical operators and comparators) and provide Unicode symbols for infix equivalents. Take for example `xor` (neé `$`), which is called as `xor(a, b)` with the infix Unicode synonym `\xor` (AKA `\veebar`). This convention provides both clarity and consistency in code.

If you need infix containment checking, I recommend `in` and `\subseteq` depending on the circumstance. As an example,

```julia
julia> "abc" ⊆ "abcd" # equivalent to contains("abcd", "abc") if you don't care about order
true

```

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 4, 2017, 7:08pm UTC](https://discourse.julialang.org/t/make-contains-infix/4644/3 "2017-07-04T19:08:31Z")

</div>

Great! Thanks for the explanation.

Just as a remark though:

```julia
julia> "aa" ⊆ "asdfsdd"
true

julia> contains("asdfsdd", "aa")
false

```

---

<div class="post-metadata">

**Author:** ![ararslan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ararslan/32/3825_2.png) [@ararslan](https://discourse.julialang.org/u/ararslan)\
**Post date:** [July 4, 2017, 7:26pm UTC](https://discourse.julialang.org/t/make-contains-infix/4644/4 "2017-07-04T19:26:16Z")

</div>

Ah right, sorry, `\subseteq` doesn’t take order into account since it’s a set-based operation. My bad.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 4, 2017, 7:30pm UTC](https://discourse.julialang.org/t/make-contains-infix/4644/5 "2017-07-04T19:30:33Z")

</div>

No worries, thanks anyways!
