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

Implement pragma(__ctfe) #15636

Closed
wants to merge 1 commit into from
Closed

Conversation

thewilsonator
Copy link
Contributor

A pragma declaration to suppress the code generation of functions it is attached to.

@thewilsonator thewilsonator added Review:Needs Approval Review:Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org Review:Needs Tests labels Sep 28, 2023
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @thewilsonator! 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: and Returns:)

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#15636"

A pragma declaration to suppress the code generation of functions it is attached to.
@RazvanN7
Copy link
Contributor

Wouldn't simply making the function a template work?

@thewilsonator
Copy link
Contributor Author

No, they are already templates. They are called and instantiated at compile time, but not at run time.

@rikkimax
Copy link
Contributor

I stated this on the N.G. thread, but this must tell the .di generator not to elide the function body.

Eliding would require a ton of work to prove it isn't used inside, or exposed outside.

@RazvanN7
Copy link
Contributor

No, they are already templates. They are called and instantiated at compile time, but not at run time.

If the template instances are only used at compile time, I would assume that they will not be codegened.
Last time I looked at the template codegen mechanism it was implemented so that if all instaces are from
speculative contexts then the body does not make it to the object code.

I don't think that this feature is needed. If there are situations where this is useful, then most likely those are compiler bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review:Needs Approval Review:Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org Review:Needs Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants