Variable Name with Cdot?

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

Γ∇²c = some terms

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

∇⋅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.

just don’t use VS Code formatted :slight_smile:

\odot ?

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

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 ⟋

1 Like

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

You could use ∇●cV ( is U+25CF, tab-completed from \mdlgblkcircle). Anything in category So (Symbol, other) is allowed in an identifier. (And, fortunately, it’s not easily confused with ∇⋅cV.)


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

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

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

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

julia> var"∇⋅cV⃗" = 1

julia> var"∇⋅cV⃗" 

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

julia> macro var(ex)

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

julia> @var(∇⋅cV⃗)

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

1 Like