-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve Expr.toString
and Type.toString
#16556
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
test performance with #quotes please: 779a382 |
performance test scheduled for 779a382: 1 job(s) in queue, 0 running. |
We now capture the context in each `Expr` and `Type` instead of the `Scope`. This context can be used to compute the `Scope`.
28295f4
to
6813913
Compare
test performance with #quotes please |
performance test scheduled: 1 job(s) in queue, 1 running. |
1 similar comment
performance test scheduled: 1 job(s) in queue, 1 running. |
Performance test finished successfully: Visit https://dotty-bench.epfl.ch/16556/ to see the changes. Benchmarks is based on merging with main (779a382) |
1 similar comment
Performance test finished successfully: Visit https://dotty-bench.epfl.ch/16556/ to see the changes. Benchmarks is based on merging with main (779a382) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What data is stored in a Context? In principle it looks cleaner to me to separate data types
like Expr and Type from the Context that prints them.
I am not seeing the motivation for the change. Can you describe what was the toString
behavior before? And what is it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still not sure this is the right way to do it. Normally, it's best to leave toString
as the low-level debug info that simple shows the tree as is. I.e. not {...}
but a case class term instead. And then there is a high-level show
method that takes
a context and prints the tree in a high-level syntax. Why is that approach not applicable here?
Replaced with #16663 |
Alternative to #16556. The default to string implementation gives more information on the expression or type than `'{...}` or `Type.of[..]`. With this string representation, we will know the class and instance hash.
With this change, the
toString
can return the same as theshow
method.We now capture the context in each
Expr
andType
instead of theScope
. This context can be used to compute theScope
.Note that the context that is captured is the same one that is captured by the
Quotes
instance. As the expressions created with thisQuotes
should not escape the splice the created thatQuotes
, theExpr
should not outlive the instance ofQuotes
. Therefore the captured context should not leak out of the macro expansion (or nested splice).Behavior