Skip to content

Remove scala.quoted.{Const, Consts} #10578

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
nicolasstucki opened this issue Dec 1, 2020 · 4 comments · Fixed by #10684
Closed

Remove scala.quoted.{Const, Consts} #10578

nicolasstucki opened this issue Dec 1, 2020 · 4 comments · Fixed by #10684
Assignees
Milestone

Comments

@nicolasstucki
Copy link
Contributor

This extractor is redundant and needs to be removed before 3.0.0-RC1 as we do not want to break the API after that.

All use case of Const are covered by simpler calls to .unlift/.unliftOrError or by the more general Unlifted extractor.

@nicolasstucki
Copy link
Contributor Author

The only valid objection so far is that the name looks better in some situations. That can be worked around using renames in imports or creating a simple Const definition outside that library that reuses the logic of Unlifted.

@liufengyun
Copy link
Contributor

#10572 (comment)

Const.unapply guarantees that no evaluation happens in the unlifting, while there is no such guarantee in using .unlift or Unlifted. Meanwhile, Const is more specific and precise when users only want to match literals in programs.

Users should use .unlift most of the time. However, it is not a replacement for Const.unapply, as
the semantics of .unlift depends on the imported Unliftable instance --- it does not provide the semantics intended by Const.unapply.

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Dec 1, 2020

Const.unapply guarantees that no evaluation happens in the unlifting, while there is no such guarantee in using .unlift or Unlifted. Meanwhile, Const is more specific and precise when users only want to match literals in programs.

Not true, both guarantee the same amount of evaluation for primitive types. Their implementation is the same code.

However, it is not a replacement for Const.unapply, as the semantics of .unlift depends on the imported Unliftable instance --- it does not provide the semantics intended by Const.unapply.

It does as that is the spec. It would not only if you implement a custom Unliftable that does not follow the spec.

@nicolasstucki nicolasstucki self-assigned this Dec 1, 2020
@nicolasstucki
Copy link
Contributor Author

The code for Const and Consts can already be found in scala.quoted.util (unpublished).

@nicolasstucki nicolasstucki linked a pull request Dec 2, 2020 that will close this issue
@nicolasstucki nicolasstucki modified the milestones: 3.0.0-RC1, 3.0.0-M3 Dec 7, 2020
@nicolasstucki nicolasstucki linked a pull request Dec 7, 2020 that will close this issue
@Kordyjan Kordyjan modified the milestones: 3.0.0-M3, 3.0.0 Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants