# Variable Name with Cdot?

**URL:** <https://discourse.julialang.org/t/variable-name-with-cdot/97838>\
**Category:** General Usage\
**Tags:** unicode\
**Created:** [April 24, 2023, 3:13am UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838 "2023-04-24T03:13:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [April 24, 2023, 3:13am UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838/1 "2023-04-24T03:13:58Z")

</div>

This may seem like a silly question. It is not really that important but if its possible I’d like to do it. I am writing some code for a fluid solver and I have terms that represent diffusion and advection. I can write the following for diffusion

```julia
Γ∇²c = some terms

```

I was going to then write my advection terms like this (where I did `\cdot` tab to get it)

```julia
∇⋅cV⃗ = some terms 

```

Problem is, the VsCode formatter thinks it is a multiplication sign so it reformats the variable to `∇ ⋅ cV⃗`.

I’m probably getting carried away with unicode here, but is there any other symbol (another type of dot maybe?) I could use to replace `cdot` and not have it confused with multiplication? I could do `∇cV⃗` but that is not the same thing mathematically (different operation) so I’d prefer not to.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [April 24, 2023, 4:23am UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838/2 "2023-04-24T04:23:59Z")

</div>

just don’t use VS Code formatted 🙂

```julia
\odot ?

```

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [April 24, 2023, 4:28am UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838/3 "2023-04-24T04:28:52Z")

</div>

iiuc OP wants an identifier character, not an operator. Perhaps `_`

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [April 24, 2023, 5:16am UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838/4 "2023-04-24T05:16:44Z")

</div>

> [@TI36XPro](#):
>
> I’m probably getting carried away with unicode here, but is there any other symbol (another type of dot maybe?) I could use to replace `cdot` and not have it confused with multiplication?

The problem with doing this is that someone who later reads the code would probably think that the expression contains an actual function call, rather than being an identifier. Or they could confuse assignment with function definition (since e.g. `x+y = ... ` redefines the `+` operator.)

Even if there should exist a technical solution to this, I’m not sure if there is a _good_ solution.

BTW, there’s a related (and simultaneous) discussion here: [Add unicode symbol ⟋](https://discourse.julialang.org/t/add-unicode-symbol/97836/1)

---

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [April 24, 2023, 11:54am UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838/5 "2023-04-24T11:54:06Z")

</div>

Yes, this occurred to me as well. Maybe that’s the answer.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 24, 2023, 1:15pm UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838/6 "2023-04-24T13:15:08Z")

</div>

> [@TI36XPro](#):
>
> is there any other symbol (another type of dot maybe?) I could use to replace `cdot` and not have it confused with multiplication?

You could use `∇●cV` (`●` is [U+25CF](https://www.compart.com/en/unicode/U+25CF), tab-completed from `\mdlgblkcircle`). Anything in [category So (Symbol, other)](https://www.compart.com/en/unicode/category/So) is allowed in an identifier. (And, fortunately, it’s not easily confused with `∇⋅cV`.)

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [April 24, 2023, 5:38pm UTC](https://discourse.julialang.org/t/variable-name-with-cdot/97838/7 "2023-04-24T17:38:39Z")

</div>

> [@TI36XPro](#):
>
> I was going to then write my advection terms like this (where I did `\cdot` tab to get it)
> 
> `∇⋅cV⃗ = some terms `

By the way, when you write this you’re actually defining a function called `⋅`:

```julia
julia> ∇⋅cV⃗ = 1
⋅ (generic function with 1 method)

julia> [1,2,3] ⋅ [1,2,3]
1

```

I think the best thing to do here would be to just use the `var` string macro:

```julia
julia> var"∇⋅cV⃗" = 1
1

julia> var"∇⋅cV⃗" 
1

```

If you don’t have any special characters in the expression, you could even do this with a non-string macro:

```julia
julia> macro var(ex)
           esc(Symbol(ex))
       end;

julia> @var(∇⋅cV⃗) = 2
2

julia> @var(∇⋅cV⃗)
2

```

That way you get things like syntax highlighting inside the `@var(...)` espression
