Either I'm just too stupid, or D is lacking something

Chad J gamerChad at _spamIsBad_gmail.com
Mon Jul 24 19:07:38 PDT 2006


Andrei Khropov wrote:
> Wolfgang Draxinger wrote:
> 
> 
>>I used a '#' since it is not being assumed a token by the D specs
>>right now.
> 
> 
> In fact it's used for special token sequences:
> http://www.digitalmars.com/d/lex.html#specialtokenseq 
> (although I don't see much use in #line)
> 

I see use for #line.
I'm not sure how practical it would be to write, but at some point I'd 
like to write or have a tool that can rewrite D source code, a 
preprocessor of sorts but not really.

It would do stuff like:
- Eliminate dead code.
- Insert things like "assert( object !is null )" just before 
"object.member".
- Automatically add "delete object;" where it can be proven at 
compile-time that object can safely be deleted.
- Source level linking - Merge a build of sourcefiles together into one 
sourcefile, possibly allowing the compiler to do better global 
optimizations. (I just had a case where changing a public method to a 
private method created about a 100x speedup in execution of that method, 
possible inlining?)
- probably more cool stuff etc...

For at least the first thing, and maybe the first few, it would be 
helpful to be able to change the line number so that the line numbers 
map back to the original source files while debugging.

<rambling>
In a way I wonder if such a tool could eventually take over some of the 
functionality provided by a D compiler; stuff that doesn't necessarily 
map directly to machine code, like array bounds checking, enums, 
constants, constant expression evalution, etc.  It would be slower 
compilation, but it could allow new D compilers to become functional 
more quickly.
</rambling>

> See also discussion here:
> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/39264
> 
> Looks like we have only '@' symbol to use.
> 
> What you are talking about is actually more powerful metaprogramming.
> I'm afraid it's postponed to D 2.0.
> 



More information about the Digitalmars-d mailing list