-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
RFC: add ability to avoid printing trailing type parameters #58389
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
base: master
Are you sure you want to change the base?
Conversation
|
This would be absolutely amazing to have in Base. |
|
why change the approach from #48444 ? is it so making a type "quiet" can happen by a third party outside of the declaration? |
|
That needed a re-do since then we didn't even have the stacktrace_types_limited flag yet, plus this is more general since you can specify how many parameters to print. I don't want third parties to be able to set this, no, but it's also not particularly harmful. |
|
Apologies if this is beyond the scope of this PR, but I'm reminded of #269, for which the workaround seems to be doing something like this: struct _IndirectFoo{_B}
a::_B
end
struct Bar
b::_IndirectFoo{Bar}
end
const Foo = _IndirectFoo{Bar}However this then means instead of |
|
What types from and there are other such examples. If this were to be avoided, then a better implementation would seem to be having a field of a staticly sized bitarray in the data type that would allow to filter out the type parameters that someone wants to print... Since most types do not have more than 8 type parameters anyway, it would not be at the cost of additional memory, correct? |
|
Yes, we could make it a bit vector instead, that might be a good idea. |
Lots of types have extra parameters added just for specialization and conveying no useful additional information. I have gotten requests for some way to avoid printing these to cut down type verbosity e.g. in stack traces. This PR adds a very minimal mechanism that does the job:
Note the limit is only applied inside the stack trace and not the exception, but that's an orthogonal feature that could be changed.
It might seem a bit un-principled to just cram a mutable integer field in there; we wouldn't necessarily want this changing all the time. Nevertheless I think this is a pretty efficient and effective way to do this. Using methods would be way too heavyweight. But, we might want to make the field constant and only set once when the type is defined, and have some macro syntax for specifying this.