What is missing from the current name printing?
- Sometimes Name.pp is used and sometimes Pp.Env and Name.to_string are used. Needs to be consistent.
- We are still shadowing global names in the signature (including constructors, data types, etc).
- Handling of variables which already have suffixes is suboptimal.
- Unnamed variables should try
x,y,z,wfor expression variables andi,j,kfor dimension variables.
LOL I was just trying to open this exact same ticket :laughing:
It's funny, it manages to not shadow just one variable, and everytihng else is shadowed. oops.
Proposal @jonsterling @ecavallo
- A named variable
ais printed as the first available ina,a₁, ...,a₉,a₁₀... - A named variable
a₂is printed as the first available ina₂,a₃, ...,a₉,a₁₀... - A named variable
a₀₂is printed as the first available ina₀₂,a₀₃, ...,a₀₉,a₀₁₀... - An unnamed variable is printed as the first available in
x,x₁, ...,x₉,x₁₀...
@favonia I think Evan and I agree this needs to be fixed, but don't care at all in what manner it is fixed :laughing:
@jonsterling For now, I have to simplify the scheme to:
- A named variable
ais printed as the first available ina,a₁, ...,a₉,a₁₀... - An unnamed variable is printed as the first available in
x,x₁, ...,x₉,x₁₀...
because I would like to use a proper UTF-8 library to strip off the suffix. (I wonder if @freebroccolo knows an immortal choice of UTF-8 libraries.)
@favonia We are already using an immortal utf-8 library (uuseg, uuseg_string)... But please, can we just do something simple? Even without the subscripts if it is easier. This (technically minor) issue is such that any fix at all would lead to a great improvement, so we really don't need to boil the ocean for it :laughing:
@jonsterling Another subtlety is that we should also avoid shadowing names in the global signature (names of datatypes, constructors, etc).
@favonia Yes, agreed!!
Proposal @jonsterling @ecavallo
* A named variable `a` is printed as the first available in `a`, `a₁`, ..., `a₉`, `a₁₀`... * A named variable `a₂` is printed as the first available in `a₂`, `a₃`, ..., `a₉`, `a₁₀`... * A named variable `a₀₂` is printed as the first available in `a₀₂`, `a₀₃`, ..., `a₀₉`, `a₀₁₀`... * An unnamed variable is printed as the first available in `x`, `x₁`, ..., `x₉`, `x₁₀`...
I agree with Jon that the current choice of libraries for unicode stuff is probably the best available.
Regarding pretty printing with the subscripts like this, I implemented something similar here. That algorithm cycles through the full alphabet ('a' - 'z') for each new subscript but it should be easy to change to just use one letter.