Skip to content

Use asRefelctTree #10287

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

Closed
wants to merge 1 commit into from
Closed

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@@ -23,7 +23,7 @@ object Const {
case Inlined(_, Nil, e) => rec(e)
case _ => None
}
rec(expr.unseal)
rec(expr.asReflectTree)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have trees other than reflect trees? What about call it reflect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have other things in reflect such as TypeRepr, Position, Symbol, ... . All things that could be taken out from this expression.

There is also a better use of reflect in #10289.

We also want the method to be a bit longer to make it pop out a bit bore in the source as this is where we go into the other API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the changes, for meta-programmers, asReflectTree seems a little verbose. What about expr.asTree?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, that was the intention. We want to stop anyone that does not need to use it for calling it in the middle of some code just because it has a short name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asTree tempted as a first option but I noticed that it was too dangerous and the changed to asReflectTree to have something that is immediately associated with reflect.Tree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only realistic alternative we have is to remove this method and create one in the module of Tree or Term.

- val tree: Term = expr.asReflectTree
+ val tree: Term = Term.of(expr)
+ val tree: Term = Tree.of(expr)

This keeps the short name and has the added advantage that we need to import qctx.reflect._ or use the path explicitly (making it clear where we change from one API to the other).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #10332 with this alternative. This alternative looks better and is more inline with the rest of the API

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a better alternative 👍

@nicolasstucki nicolasstucki marked this pull request as ready for review November 12, 2020 15:59
@nicolasstucki nicolasstucki added this to the 3.0.0-M2 milestone Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants