dmd
dmd copied to clipboard
Implement pragma(ctfe)
Rebase of https://github.com/dlang/dmd/pull/11014, which was stalled because of a trailing whitespace. I made a new PR because the rebase was non-trivial and a force push is risky, and it seems the original author is no longer active here.
This came up in the forum again: https://forum.dlang.org/post/[email protected]
Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:
- My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
- My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
- I have provided a detailed rationale explaining my changes
- New or modified functions have Ddoc comments (with
Params:andReturns:)
Please see CONTRIBUTING.md for more information.
If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.
Bugzilla references
Your PR doesn't reference any Bugzilla issue.
If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
Testing this PR locally
If you don't have a local development environment setup, you can use Digger to test this PR:
dub run digger -- build "master + dmd#14036"
Currently this works by effectively saying if(betterC && !pragmaCTFE). It would be worth investigating whether this can be changed to effectively turning betterC off during semantic analysis of symbols with this pragma, partly because dmd is already full of Kafkaesque if statements, but also because this is a route to making all use of D at CTFE inside WorseD more tolerable (this is more complicated than just what is mentioned here, however this is the framework).
@WalterBright @atilaneves What do you think of this feature? You can find a description in the changelog entry: https://github.com/dlang/dmd/blob/63b7594e546221aa5aaa34f64bff7f71fd90c64d/changelog/pragma_ctfe.dd
but also because this is a route to making all use of D at CTFE inside WorseD more tolerable (this is more complicated than just what is mentioned here, however this is the framework).
TypeInfo is being phased out with the project to translate the relevant druntime hooks to templates, so this might just solve itself.
I like the feature but am wondering about the approach from a syntax perspective.
but also because this is a route to making all use of D at CTFE inside WorseD more tolerable (this is more complicated than just what is mentioned here, however this is the framework).
TypeInfo is being phased out with the project to translate the relevant druntime hooks to templates, so this might just solve itself.
but also because this is a route to making all use of D at CTFE inside WorseD more tolerable (this is more complicated than just what is mentioned here, however this is the framework).
TypeInfo is being phased out with the project to translate the relevant druntime hooks to templates, so this might just solve itself.
There's more to it than typeinfo
I've thought about this a bit more recently and we should aim for assert(_ctfe) rather than a pragma if possible.
Superseded by recent improvements in betterC's CTFE handling