Skip to content

Add libraries that require replacement for Evals.eval #11

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

Merged
merged 1 commit into from
May 5, 2020

Conversation

plokhotnyuk
Copy link
Contributor

@plokhotnyuk plokhotnyuk commented May 4, 2020

Libraries have a couple of use cases where Evals.eval was used in compile-time:

  1. for expensive calculations of LUT tables that should happen in compile-time and produce resulting array of primitives (one possible solution provided below in comments, but it leads to code duplication between Scala 2 and Scala 3 codebases) The proposed solution for Scala 3 is here.
  2. for injecting user-defined pure functions that configure behavior during macro expansions, so should be instantiated and called in compile-time (sort of a principal problem due Scala 2 macros cannot use parameters that are not expressions)
  3. as workaround for getting of Java enumeration values in compile time for Scala 2.11 (can be easily moved to Scala 2 only codebase) Fixed by using Magnolia's code for getting of companions.
  4. as workaround for getting of parameter values of macro annotations for cases when it cannot be done by simple pattern matching (Scala 2 compiler allows expression in definitions of macro annotations but doesn't reduce them to constants automaticaly)

Any feedback will be greatly appreciated!

@julienrf julienrf requested a review from nicolasstucki May 4, 2020 16:45
@plokhotnyuk
Copy link
Contributor Author

Also, specs2 uses Evals.eval in its type check implementation

@nicolasstucki
Copy link
Collaborator

The first one can be ported using scala/scala3#8878

@adpi2 adpi2 merged commit 42ac320 into scalacenter:master May 5, 2020
@julienrf
Copy link
Contributor

julienrf commented May 5, 2020

The first one can be ported using lampepfl/dotty#8878

Would you have some time to include an explanation of the migration in this guide?

@adpi2
Copy link
Member

adpi2 commented Sep 25, 2020

@nicolasstucki @plokhotnyuk
Is this "No replacement for Evals.eval" still relevant? Is there a discussion somewhere on that topic?

@nicolasstucki
Copy link
Collaborator

It is probably relevant. Not sure if there is a discussion somewhere.

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.

4 participants