-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[DRAFT] Allow customisation of metaprogramming via scalac flags #12039
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
Hi @japgolly, do you plan to work any more on this?, we are trying to clean up open PR |
@bishabosha @nicolasstucki Conditionally, yes! Let me give some context: After raising this I thought I might be able to implement this as a compiler plugin instead. I made some progress in https://github.com/japgolly/ctenv but ended up stopping because it just seemed way too hard because a plugin can't intercept the calls at the ideal time/phase. Instead it became a huge hackfest where I retrospectively tried to patch generated ASTs and ultimately it's just not feasible. You can partially get it working a simple cases but it's super brittle and impossible to have it work reliably. OTOH, this implementation here was super easy. It would be great to pick this up again, and I'm conditionally willing to update and maintain the PR to get it merged. The reason I say conditionally is that I don't wont to get more invested and spend lots of effort only for this to end up in the bin so I think the first step would be to discover whether or not this would really be accepted. I love to get the concept approved in some form before working further on the implementation. I think @nicolasstucki (or was it @bishabosha?) had some concerns about the impact on tasty. So if code is compiled with scalac flags specifying |
Oh, other potential concerns:
It seems to me that the compile-time env should only persist for the current compilation phase, and not be transitive. I don't foresee any problems with that and it would be a much simpler design, but would love to hear any counter points of view. |
@@ -156,6 +156,25 @@ inline def summonAll[T <: Tuple]: T = | |||
res.asInstanceOf[T] | |||
end summonAll | |||
|
|||
@compileTimeOnly("Illegal reference to `scala.compiletime.envGetOrNull`") | |||
transparent inline def envGetOrNull(inline key: String): String | Null = |
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.
This kind of logic should be in the reflection interface first. If it is, this method can be implemented in any external library.
Lack of Regarding reproducibilty: Reading from environment is a side effect; side-effecting macros cannot be and aren't meant to be reproducible - instead they are used for their side effects, which by design may differ in each build. I hope that's not a deal breaker for Tasty recompilation – before I assumed that applied macros would be expanded to their resulting tasty trees and wouldn't have to be re-executed for recompilation – requiring re-execution would impose a lack of side effects on macros which would be a heavy restriction to work with. [1] - I'm biased towards keeping the existing name and API from Scala 2, rather than renaming to |
…Scala2 added @Experimenta annotation to new API method modified message, according to review Update library/src/scala/quoted/Quotes.scala Co-authored-by: Nicolas Stucki <[email protected]> settings -> XmacroSettings added CompilationInfo.XmacroSettings to MiMaFilters corrected MiMaFilters added examples from scala#12039 with workarround against scala#14245 Co-authored-by: David Barri <[email protected]>
…Scala2 added @Experimenta annotation to new API method modified message, according to review Update library/src/scala/quoted/Quotes.scala Co-authored-by: Nicolas Stucki <[email protected]> settings -> XmacroSettings added CompilationInfo.XmacroSettings to MiMaFilters corrected MiMaFilters added examples from scala#12039 with workarround against scala#14245 Co-authored-by: David Barri <[email protected]> remove trailing '\n' from file
…Scala2 added @Experimenta annotation to new API method modified message, according to review Update library/src/scala/quoted/Quotes.scala settings -> XmacroSettings added CompilationInfo.XmacroSettings to MiMaFilters corrected MiMaFilters added examples from scala#12039 with workarround against scala#14245 remove trailing '\n' from file Co-authored-by: David Barri <[email protected]> Co-authored-by: Nicolas Stucki <[email protected]>
…cala2 added test-case from scala#12039 with workarround against changes in compiler Co-authored-by: David Barri <[email protected]> Co-authored-by: Nicolas Stucki <[email protected]>
…cala2 added test-case from scala#12039 with workarround against changes in compiler Co-authored-by: David Barri <[email protected]> Co-authored-by: Nicolas Stucki <[email protected]>
Fixes #12038
Disclaimer: the names used are just drafts and still need some good bikeshedding, and some parts of this need some tidying up. This PR is currently for feedback.