Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR brings a design proposal using Kotlin
Context Parametersfeature to Macros API. The idea is to use the power of context parameter to build elegant and simple macro code, the proposals are:Context Parameter in Macro functions
Now developers can write macros using the benefits of context parameters:
Some internal functions were also improved, for example
propertiesthat is a new version ofpropertiesOf, letting all macro construction more idiomatic and simple.Changes in
TransformClassCompilationThe proposal in this compilation is to improve members construction in this compilation, so instead of:
firClass.transform { property { """ val b = 2 """ } function { """ fun a() {} """ } function { """ fun b() {} """ } }This PR proposes:
firClass.transform { """ val b = 2 """.property().create() """ fun a() {} """.function().create() """ fun b() {} """.function().create() }I'm not totally against curly braces style but I feel it's more clear and simple if we try to let this class transformation scope linear. The idea to divide
createfunction frompropertyandfunctionfunctions for example, is to separate its concerns lettingcreatefunction type safe but let me know if you prefer another approach like"val b = 2".createProperty()and"fun a() {}".createFunction