-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Bug 3952d: __ctfeWriteln #296
Conversation
|
+1 from me, this is certainly helpful for debugging CTFE functions and tracing down CTFE bugs. However, I still don't get why there is no |
|
@klickverbot: As you can see, it makes it hard to find errors. Plus, if its sole purpose is for debugging, this ought to be fine. If you need a write then I guess you'd have to use a buffer of some sort. |
|
@mrmonday: Obviously, you have to be careful about including newlines at the right places, but what is especially hard to do within the boundaries of CTFE? Right, keeping state (e.g. a buffer for collecting non-newline messages) without explicitly passing it around to all involved parties. And especially when a feature is used only for debugging purposes, I'd argue that it should be flexible enough to be just thrown in at some place in for some debugging output, not the other way round. Another reason why I think restricting CTFE output to including newlines is not the best idea is because at least in my experience, CTFE especially lends itself to functional-style recursive algorithms, where processing of a single entity is spread across a number of function calls, and thus adding a buffer to avoid the automatically appended newline would require temporary modifications to several function signatures. To wrap it up, I just don't get why we should want to introduce a completely artificial, hard to work around limitation, just for … whatever real reasons there are for it anyway. Yes, of course, in many cases you want your debugging output to be terminated by a newline anyway, but especially in cases where the user cannot easily avoid them an alternative, I think we should think twice about the motivations before putting restrictions into place. Concerning the example output you posted (there probably would be a newline after »some other error«, btw), this problem could be easily avoided by the compiler forcing a newline before writing an error message, or if the output of |
|
This pull request cannot be automerged. (A friendly reminder!) |
Conflicts: src/attrib.c src/statement.c
|
Superseded by #692. |
Make DMD recognize the
__ctfeWritelnfunction at interpret-time, and print the arguments to console when used.Note: dlang/druntime#52 need to be pulled as well.
For example, the code
will print
when compiling.
This is not a replacement of
pragma(msg).(BTW, Phobos's
writelncan still behave like #237 by adding a CTFE version:)