algaett icon indicating copy to clipboard operation
algaett copied to clipboard

What is missing from the current name printing?

Open favonia opened this issue 7 years ago • 8 comments

  1. Sometimes Name.pp is used and sometimes Pp.Env and Name.to_string are used. Needs to be consistent.
  2. We are still shadowing global names in the signature (including constructors, data types, etc).
  3. Handling of variables which already have suffixes is suboptimal.
  4. Unnamed variables should try x,y,z,w for expression variables and i, j, k for dimension variables.

favonia avatar Sep 17 '18 06:09 favonia

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.

jonsterling avatar Sep 17 '18 13:09 jonsterling

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₁₀...

favonia avatar Sep 21 '18 11:09 favonia

@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 avatar Sep 21 '18 12:09 jonsterling

@jonsterling For now, I have to simplify the scheme to:

  • 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₁₀...

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 avatar Sep 21 '18 12:09 favonia

@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 avatar Sep 21 '18 12:09 jonsterling

@jonsterling Another subtlety is that we should also avoid shadowing names in the global signature (names of datatypes, constructors, etc).

favonia avatar Sep 21 '18 13:09 favonia

@favonia Yes, agreed!!

jonsterling avatar Sep 21 '18 13:09 jonsterling

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.

ghost avatar Sep 21 '18 15:09 ghost