Skip to content

Move quoted null and unit encoding to internal #9551

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

nicolasstucki
Copy link
Contributor

No description provided.

These are opimizations for `'{}`/`'{()}` and `'{null}` which should not be used directly
@nicolasstucki nicolasstucki force-pushed the move-quoted-null-and-unit-encoding-to-internal branch from 518c51a to 566bdf5 Compare August 13, 2020 12:24
@nicolasstucki nicolasstucki marked this pull request as ready for review August 13, 2020 13:24
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

Otherwise, LGTM

def Unit: QuoteContext ?=> quoted.Expr[Unit] = qctx ?=> {
import qctx.tasty._
Literal(Constant(())).seal.asInstanceOf[quoted.Expr[Unit]]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems both can be val instead of def?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They could but they would not get the optimization where the context parameter is passed directly as one of the method parameters and the closure is not created. We effectively call the following method at runtime (not closure creation needed):

def Unit(using q: QuoteContext): quoted.Expr[Unit] = {
  import qctx.tasty._
  Literal(Constant(())).seal.asInstanceOf[quoted.Expr[Unit]]
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, maybe we can write it directly, instead of the original form?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is like this to align with the quote internal encoding to simplify the transformation.

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 will consider changing the encoding but this is a larger change that will take some time to accomplish.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification, it makes sense.

@nicolasstucki nicolasstucki merged commit 17c5dc1 into scala:master Aug 14, 2020
@nicolasstucki nicolasstucki deleted the move-quoted-null-and-unit-encoding-to-internal branch August 14, 2020 14:43
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