Skip to content
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

Add a CPP flag for each available DAML-LF feature. #2896

Merged
2 commits merged into from
Sep 16, 2019
Merged

Add a CPP flag for each available DAML-LF feature. #2896

2 commits merged into from
Sep 16, 2019

Conversation

ghost
Copy link

@ghost ghost commented Sep 13, 2019

Closes #99. This PR adds CPP flags for each DAML-LF feature declared in DA.Daml.LF.Version. The CPP flag is only passed when compiling to a DAML-LF version that supports that feature.

Right now, it only adds the DAML_NUMERIC CPP flag which will be used in the standard library implementation of Numeric types (see #2289). The advantage of doing things this way is that the mapping between features and versions is kept in a central location (DA.Daml.LF.Version), so they only need to be updated there.

@ghost ghost requested review from cocreature and hurryabit September 13, 2019 13:10
@digitalasset-cla
Copy link
Member

digitalasset-cla commented Sep 13, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cocreature cocreature left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, I like how simple this has turned out! Also very much in favor of having feature flags instead of version flags, reminds me of https://github.com/quchen/articles/blob/master/haskell-cpp-compatibility.md in a good way 🙂

@ghost ghost merged commit dc32abb into master Sep 16, 2019
Copy link
Contributor

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. Thanks a lot.

@@ -199,7 +199,7 @@ _whenRuntimeSupports version feature t e
| otherwise = runtimeUnsupported feature t

runtimeUnsupported :: Feature -> Type -> Expr
runtimeUnsupported (Feature name version) t =
runtimeUnsupported (Feature name version _) t =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove this function now. This was our old hack around the fact that the stdlib could not depend on the DAML-LF version we're compiling to.

@hurryabit hurryabit added this to the DAML Customer Happiness milestone Oct 9, 2019
@garyverhaegen-da garyverhaegen-da deleted the daml-cpp branch July 16, 2020 11:14
This pull request was closed.
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.

Use CPP to make daml-stdlib depend on DAML-LF version
3 participants