# Can I use \\parallel or \\perp in variables' names

**URL:** <https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120>\
**Category:** General Usage\
**Created:** [March 28, 2021, 3:14pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120 "2021-03-28T15:14:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Post date:** [March 28, 2021, 3:14pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/1 "2021-03-28T15:14:01Z")

</div>

Some unicode symbols cannot be used in variables’ names.  
For example,

```julia
julia> C∥ = 1
ERROR: syntax: unexpected "="
Stacktrace:
 [1] top-level scope at none:1

julia> C⟂ = 2
ERROR: syntax: unexpected "="
Stacktrace:
 [1] top-level scope at none:1

```

However, this works

```julia
julia> ∥ = 1
1

```

Combinations of normal symbols and \perp or \parallel are not allowed.  
Is there a reason for this behavior? If so, is there a workaround so that I can use them in names?

---

<div class="post-metadata">

**Author:** ![jcook](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jcook/32/18211_2.png) [@jcook](https://discourse.julialang.org/u/jcook)\
**Post date:** [March 28, 2021, 3:19pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/2 "2021-03-28T15:19:17Z")

</div>

For perpendicular you can use `\bot` and for parallel I use `z` in the absence of something closer to parallel lines that aren’t parsed as `or`.

---

<div class="post-metadata">

**Author:** ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Post date:** [March 28, 2021, 3:39pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/3 "2021-03-28T15:39:45Z")

</div>

Good. \bot is a good replacement for \perp.  
I’m still curious why some symbols are not allowed.  
I’ve tried several like ⥣ or ⦷ and they are like \perp and \parallel.  
Allowing them in the variables’ names should help the readability.

---

<div class="post-metadata">

**Author:** ![WschW](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wschw/32/6575_2.png) [@WschW](https://discourse.julialang.org/u/WschW)\
**Post date:** [March 28, 2021, 3:51pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/4 "2021-03-28T15:51:52Z")

</div>

Those unicode symbols are operators and are parsed specially. You can see the full list of operators here:  
[https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm](https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm)

---

<div class="post-metadata">

**Author:** ![FPGro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fpgro/32/20822_2.png) [@FPGro](https://discourse.julialang.org/u/FPGro)\
**Post date:** [March 28, 2021, 3:56pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/5 "2021-03-28T15:56:34Z")

</div>

You can make a variable named `C∥` with `var"C∥"` but you have to use the var thing everywhere then so thats a pretty ugly workaround

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 28, 2021, 4:43pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/6 "2021-03-28T16:43:05Z")

</div>

To give an example of the intended use of these symbols, you could define `∥` as an operator that checks if two vectors are colinear:

```julia
julia> using LinearAlgebra

julia> a∥b = norm(a)*norm(b) ≈ abs(a⋅b);

julia> [1,2,3] ∥ [2,4,6]
true

julia> [1,2,3] ∥ [2,4,7]
false

```

---

<div class="post-metadata">

**Author:** ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Post date:** [March 28, 2021, 5:25pm UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/7 "2021-03-28T17:25:08Z")

</div>

@WschW Thanks for the explanation.

@FPGro Thanks, it is indeed not a good solution… `C_para` might be better than `var"C∥"`.

@sijo Thanks, the example is neat.

Since those symbols are hardcoded in the parser, it seems there is no way to workaround this.  
The best alternative I can find is probably `C\_=`, which gives a subscript equal sign.

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 29, 2021, 7:15am UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/8 "2021-03-29T07:15:51Z")

</div>

> [@linwaytin](#):
>
> The best alternative I can find is probably `C\_=` , which gives a subscript equal sign.

You might also like these ones:

```julia
julia> 'ǁ'
'ǁ': Unicode U+01C1 (category Lo: Letter, other)

julia> '║'
'║': Unicode U+2551 (category So: Symbol, other)

julia> '┴'
'┴': Unicode U+2534 (category So: Symbol, other)

```

---

<div class="post-metadata">

**Author:** ![linwaytin](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Post date:** [March 29, 2021, 11:20am UTC](https://discourse.julialang.org/t/can-i-use-parallel-or-perp-in-variables-names/58120/9 "2021-03-29T11:20:40Z")

</div>

These are amazing! Thanks.
