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 __ctfeWrite builtin #16250
Conversation
Reworked stalled PR dlang#12412. The __ctfeWrite function is already part of druntime (core.builtins), but was never implemented. The actual implementation is the one used at Weka (slightly different from PR dlang#12412) and does not require any changes to expression.d (contrary to said PR).
Thanks for your pull request and interest in making D better, @JohanEngelen! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
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 referencesYour 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 locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#16250" |
@@ -448,6 +448,8 @@ immutable Msgtable[] msgtable = | |||
{ "outp"}, | |||
{ "outpl"}, | |||
{ "outpw"}, | |||
{ "builtinsModuleName", "builtins" }, |
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.
note the conflict with importC's builtins.d druntime file; that one has a very unfortunate (and confusing) name...
Weka has more experience with this, so I suggest doing what fits you best. Also, we should probably also have some documentation for this feature even if it's not intended for the regular user to use it. |
|
If written to stdout, don't be surprised if you get assembler errors when combined with |
Do you mean that it would be hard/impossible to implement "to stdout" for GDC ? So that it has to be implementation defined, anyways? |
Yes, |
PR is ready. |
@JohanEngelen This also requires a spec PR. |
Where? |
Well, it depends on how you look at it. The druntime implementation does nothing. As far as I could tell from the previous PRs the only point of having it declared in druntime is to be able to type check calls to Arguably, having __ctfeWrite defined in druntime is something that could be avoided. |
The changelog entry is actually identical to the existing documentation of the druntime function! (literally almost word-for-word indentical).
Maybe. But none of the builtin functions are documented in the spec. So my question remains: Where do you want it in the spec? |
Here: https://dlang.org/spec/function.html#interpretation . Next to |
@JohanEngelen what do you mean? I don't see any documentation for the druntime function apart from: https://github.com/dlang/dmd/blob/master/druntime/src/core/builtins.d#L52 . Whereas the changelog is much more explanatory, it even provides an example (I would also add an example to highlight the difference between __ctfeWrite and pragma(msg)). |
Reworked stalled PR #12412.
The __ctfeWrite function is already part of druntime (core.builtins), but was never implemented. The actual implementation is the one used at Weka (slightly different from PR #12412) and does not require any changes to expression.d (contrary to said PR).
One open issue: currently stderr is hardcoded. Is this "implementation defined" or not, or should we add a second parameter that enables the user to select between stdout and stderr? I actually prefer this last option, i.e. changing signature to
__ctfeWrite(scope const(char)[] s, bool to_stderr = true)
.For reference, the output of
pragma(msg, ...)
to stderr is implementation defined (https://dlang.org/spec/pragma.html#msg)