Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow \u2e12 in variable names #34835

Open
ChrisRackauckas opened this issue Feb 21, 2020 · 7 comments
Open

Allow \u2e12 in variable names #34835

ChrisRackauckas opened this issue Feb 21, 2020 · 7 comments
Labels
parser Language parsing and surface syntax unicode Related to unicode characters and encodings

Comments

@ChrisRackauckas
Copy link
Member

This came up in https://github.com/JuliaDiffEq/ModelingToolkit.jl/issues/247 where u₁⸒₂ would be great name for a generated symbolic variable in a matrix, but it is not allowed with the current punctuation rules in the parser. I would advocate for allowing this inside of variable names since right now it doesn't have another use.

@JeffreySarnoff
Copy link
Contributor

JeffreySarnoff commented Feb 21, 2020

mᵢ⸒ⱼ⸒ₖ

@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label Feb 21, 2020
@JeffBezanson
Copy link
Member

Is there a latex sequence for this?

@JeffBezanson JeffBezanson added the unicode Related to unicode characters and encodings label Feb 21, 2020
@JeffreySarnoff
Copy link
Contributor

JeffreySarnoff commented Feb 21, 2020

Not per se afaik. ($$m_{i,j,k}$$) ($_,$) though

@ChrisRackauckas
Copy link
Member Author

Indeed the Latex we generate as output do m_{i,j,k}, but we can't have that as a variable name so we are trying to get as close as possible:

https://github.com/JuliaDiffEq/ModelingToolkit.jl/blob/v1.2.7/test/latexify.jl#L38-L51

Essentially what we're doing is taking in data and then spitting out the Latex for the physical laws that would generate the data, so we're trying to make our symbolic variables on the Julia side be symbols that are close to the Latex to make it easier to read and relate (since we're generating Julia code for the functions as well). What we're missing is a unicode subscript comma.

@StefanKarpinski
Copy link
Member

It seems like it should be input as \_,<tab>.

@JeffreySarnoff
Copy link
Contributor

JeffreySarnoff commented Feb 21, 2020

There is also \u02cf 'ˏ' mᵢˏⱼˏₖ and \u201A '‚' mᵢ‚ⱼ‚ₖ (vs '⸒' mᵢ⸒ⱼ⸒ₖ using \u2e12) either is more comma-like and available in many more fonts (these lists do not include recently released fonts):
~10 font families supporting \u2e12 (mᵢ⸒ⱼ⸒ₖ)
~100 font families supporting \u201a (mᵢ‚ⱼ‚ₖ)
~40 font families supporting \u02cf (mᵢˏⱼˏₖ)

IBM Plex Mono has \u201a \u02cf, does not have \u2e12
FiraMono, Roboto Mono, Hasklig have \u201a, do not have \u02cf \u2e12

Given the lesser availability of \u2e12, one of the alternatives is preferable.

@knuesel
Copy link
Member

knuesel commented Feb 25, 2021

u+201a actually looks too nice, i.e. it's too hard to distinguish from a regular comma: mᵢ‚ⱼ‚ₖ vs mᵢ,ⱼ,ₖ.

In a sense, that u+02cf looks a bit weird is an advantage, as it makes it clear that it's not a regular comma: mᵢˏⱼˏₖ vs mᵢ,ⱼ,ₖ (this is also true of u+2e12). This is what ModelingToolkit uses now.

There is also u+02cc "modifier letter low vertical line": mᵢˌⱼˌₖ. It is distinguishable from a regular comma, present in many fonts, and already allowed in variable names (this is all also true of u+02cf).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax unicode Related to unicode characters and encodings
Projects
None yet
Development

No branches or pull requests

5 participants