Why does RDMD evaluate templates twice?
    Andrej Mitrovic 
    none at none.none
       
    Wed May 18 19:06:32 PDT 2011
    
    
  
This is a very odd behavior I've been seeing for quite a while now with RDMD. DMD doesn't recreate this behavior.
Take this module:
module test;
template Foo(T)
{
    pragma(msg, "test");
}
alias Foo!int a;
// alias Foo!double b;
void main()
{    
}
Notice one of the instantiations is commented out. $ is my prompt, > are the printed results:
$ rdmd test.d
> test
> test
$ rdmd test.d
> test
The first time I run it, it instantiates (or evaluates) the template twice. The second time I run rdmd, with no changes to the module, it only evaluates the template once.
Now I comment out the second instantiation in the module and try again:
$ rdmd test.d
> test
> test
> test
> test
$ rdmd test.d
> test
> test
Quite weird.  I'm thinking this could cause some kind of slowdown. Anyone have a clue what's going on here?
    
    
More information about the Digitalmars-d-learn
mailing list