-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Mixin gen #426
Mixin gen #426
Conversation
Hmm what about template mixins? |
Mixin templates are merely general templates with different instantiation scope |
I think we can use
output (in compilet time):
What is the advantage of this proposal than a library way? |
The advantage is that the debug output gets proper file and line information. |
Does this also fix error message line numbers? |
It could if the files were written before parsing and not afterwards. |
vote up, useful feature to switch on/off often, much more suited for compiler than library |
So, no love for this, then? |
Imho integrating this with the compiler makes a lot of sense, as it allows us to generate correct debug info for metaprogramming/string mixin-heavy code (this is a huge problem in practice). Only nitpick: The command line option description should state more clearly that this is just a debugging aid – as the average DMD user, I would wonder what a »mixin file« is… |
Do you have any idea?
It does by now. The mixin code is appended before parsing and the AST has line number information pointing to the mixin file. |
How about "generate a file with all string mixins expanded (primarily useful for debugging)"? |
(background: I'm doing a review of pull requests < 1000 as they tend to be controversial) I think this has great promise, but we should rethink it. Large string mixins are arbitrarily difficult to compute (think parser generators, regexen, and such). What we really want is not to dump mixins in a file for future human examination, but develop a simple and coherent system for saving generated mixins across compilations - a sort of "precompiled mixins" if you wish. That way the compiler seeing ctRegex!"[0-9A-Z-a-z][0-9A-Z-a-z_-]*" will dump the generated string once and then reuse it unless it detect it must re-generate it. That is a nontrivial task but, I think, one well worth thinking about if we want to scale up generative programming in D. |
Issue 7476 - Write(ln) functions no longer accept retro range
This pull is only about human examination. I made this because it fixes error messages and debug information. Both of which were already unvaluable tools for developing a lexer generator (https://github.com/dawgfoto/lexer).
That sounds like Make or rdmd, doesn't it?
We could look into saving compressed, serialized parse trees at some point. This would benefit normal compilation too. |
Issue 9068 - fix compiler error when breaking from some labelled loops.
- this greatly simplifies to debug mixins - the usual -Mf -Md variants are implemented as well - needed to fix File::appendv and add File::append for POSIX
The problem remains that debug info can't reference generated source code. |
I'll close this for now pending further insights. |
I think we should consider reopening this. As dawgfoto said, this pull is only about human examination (debugging), not about compilation caching. |
This pull adds a new command line option -M (-Mf, -Md).
When set string mixins are written to a separate file, which by default
carry a .mixin extension.
The logic for the files paths matches that of header generation.
The main benefits of adding this option are the simpler visibility of the
code vs. using pragma(msg) and fixing debug line information
which made it previously almost impossible to debug mixins.
I had to fix File::appendv and add File::append for POSIX.