-
Notifications
You must be signed in to change notification settings - Fork 40
Use feature flags for extern definitions #427
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
a3e7cbc to
ab5e370
Compare
|
Design decision reg. Effekt code in extern definitions: Upside: The backends can do whatever they want with it. Downside: This has to be handled in the backends, which is non-trivial at least in LLVM. Alternative: Choose the "correct" extern definition in |
|
I don't think I understand your proposal. Do you have an example of how this looks like? |
Does this refer to the whole PR/the source syntax? - In this case, there is an example in the syntax section above. Parenthesis are always required to make parsing feasible, currently they contain expressions. Alternatively, we could use If it is about the (implementation) Design Decision:
|
|
Note to self: Add a simple phase on core to select & desugar extern defs (the backends can decide to use it or not) |
|
Changed:
|
ba9bff1 to
fdbd89b
Compare
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 is the phase resolving extern defs
|
At some point we might want to move the warnings at |
|
Tests are failing because of tests that use definitions like |
0d39359 to
3d9b80e
Compare
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 is just a bad test (already has been), not your fault
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.
I tried to fix it up, and it found a bug: We cannot actually call any operations on f since the capture is not allowed by our current implementation of Typer here.
Just allowing this in typer, however, leads to crashes in the backends (more precisely: undefined variables). I think this might be related to not passing the captures to the extern 🤔.
|
|
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.
Potentially risking conflicts with String this could be shortened to
enum ExternBody extends Tree {
def featureFlag: FeatureFlag
case String(featureFlag: FeatureFlag, contents: Template[Pure])
case EffektExternBody(featureFlag: FeatureFlag, body: Stmt)
}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.
I'm not sure it's worth it given the potential conflicts. In particular, adding any helper methods on ExternBody that use Strings as parameters/return values would become awkward (and might not be that unlikely).
Maybe we can also come up with a better name (I couldn't, hence the not entirely helpful one... -s, actually).
5330db7 to
0cb52d2
Compare
This fixes the compile errors for some reason ?!?!?
|
https://github.com/effekt-lang/effekt/actions/runs/8736009035/job/23969998216?pr=427#step:9:718 |
|
Maybe it would be better to move the Resolving further to the front after all. |
|
The approach of adding it after Typer does not work properly either: The calling-convention issue hinges on the symbol type used in effekt/effekt/shared/src/main/scala/effekt/core/Transformer.scala Lines 635 to 638 in ee905df
|
In core.Tree and later ones, don't have a list anymore (or EffektExternBody), since those are now resolved before core.Transformer. This makes writing the backends easier.
effekt/shared/src/main/scala/effekt/generator/js/TransformerMonadic.scala
Show resolved
Hide resolved
effekt/shared/src/main/scala/effekt/generator/js/TransformerMonadic.scala
Outdated
Show resolved
Hide resolved
effekt/shared/src/main/scala/effekt/generator/js/TransformerMonadic.scala
Outdated
Show resolved
Hide resolved
effekt/shared/src/main/scala/effekt/generator/llvm/Transformer.scala
Outdated
Show resolved
Hide resolved
|
I reviewed the Scala source changes and they look mostly good to me. I only have a few remarks: |
|
(interpreted that as approval) |
This implements feature flags for externs.
Syntax
(Note: You might not want to use
defaultlike this... Just an example.)The old syntax should still work and is equivalent to having just a
defaultclause.This also exists for includes like this:
Notes about implemented behaviour
Current behaviour is:
defaultstring will give out a warningFuture work
Namerinto a separate phase, potentially with some other smaller checks. Alternatively: Move toResolveExternDefs.