-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Unify CanonicalVar
and DebruijnIndex
#49887
Comments
Can we pick some better names while we're at it? |
Which names are you thinking we should change? |
|
Hmm. I suppose we could call it |
If there is a very precise technical term for something, it's least ambiguous if you give that something the name. Giving something a more friendly, and less descriptive name, means that people who know the term won't be immediately familiar with it, whereas people who aren't familiar with the concept still need to look it up anyway. Plus, technical terms are more memorable. I'd prefer to stick with |
Even though DeMorgan Machine is generally a more precise technical term for computers today, we use the term computer, since it had a more generally understandable meaning for those involved, even if that term was nonsense when applied to a machine at the time. I don't think "math calls it X" is a great argument in a code base meant to be read by programmers, who may or may not have a degree in mathematics. |
This might be a reasonable argument about technical terms (e.g. (Although now that I've just noticed, I would be in favour of changing the capitalisation on the name ;) ) |
Also, aren't many canonical vars bound at the same binder? How would that work? |
This does seem like a case where a vague, non-"scary" term might be more obfuscating in practice than the technically correct, unambiguous term. imo, if |
@Ixrec AIUI, it's specifically "how many |
I think I would like to give this a shot. But this is currently blocked by #49813, isn't it? My opinion on the naming: I prefer the name |
@fabric-and-ink yeah this is sort of a "meta issue" |
but I'll try to comment here or ping you once we get #49813 resolved |
cc @fabric-and-ink — still interested in giving this a shot? #49813 is finally closed. |
I guess a good first step would be to convert |
Ok! I will do my best. |
The next step would be to replace |
…atsakis Declare DebruijnIndex via newtype_index macro Part of #49887 Declare `DebruijnIndex` via the `newtype_index` macro.
@fabric-and-ink argh sorry for missing your update! probably yes! Let me give a look |
Ok, let me know then :) |
Replace CanonicalVar with DebruijnIndex Close #49887
From #49810:
General instructions:
The canonical var is a "new type index" declared here:
rust/src/librustc/ty/sty.rs
Line 1107 in 3242880
We would basically just want to remove it completely and replace uses of it with
DebruijnIndex
. There are a few complications to be overcome. One is that debruijn indices are currently 1-based (that is #49813), so indexing with them will require some tweaks. Another related problem is thatDebruijnIndex
does not implement theIdx
trait, so we can't presently have aIndexVec<DebruijnIndex>
, as we do in theCanonicalVarValues
struct:rust/src/librustc/infer/canonical.rs
Lines 76 to 78 in 3242880
This is not that big a deal -- we can just use a plain vector -- although if we make debruijn indices 0-based we could then generate it with the
newtype_index!
macro, which would be nice.The text was updated successfully, but these errors were encountered: