aliases and .stringof

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Mon Apr 14 12:01:08 PDT 2014


I noticed something odd with code of mine with recent D builds (recent from-git 
dmd, 2.065-branch ldc2).  I have a loop in my graph library which goes:

     foreach (G; TypeTuple!(IndexedEdgeList, CachedEdgeList))
     {
         foreach (directed; TypeTuple!(false, true))
         {
             alias Graph = G!directed;
             StopWatch watch;


             writeln("Graph type: ", (Graph.directed) ? "directed " : 
"undirected ", Graph.stringof);
             // ... etc.
         }
     }

Now, with earlier compiler versions, that would have resulted in output,

     Graph type: undirected IndexedEdgeList
     Graph type: directed IndexedEdgeList
     Graph type: undirected CachedEdgeList
     Graph type: directed CachedEdgeList

But with more recent compiler versions, what I'm seeing instead is:

     Graph type: undirected G!(false)
     Graph type: directed G!(true)
     Graph type: undirected G!(false)
     Graph type: directed G!(true)

Is this a bug, or an intended change in behaviour with respect to aliases?  I 
have to say that in this case at least it feels very problematic, as it 
completely obfuscates the actual types being used, and the whole point of what's 
being output is to display the type.


More information about the Digitalmars-d-learn mailing list