www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DMD 2.042 -- what happened to ModuleInfo.name?

reply Trip Volpe <mraccident gmail.com> writes:
I recently upgraded from DMD 2.03something to the latest alpha. Previously, I
was able to do this:

import std.stdio;
import core.runtime;

void main() {
   foreach( m; ModuleInfo ) {
      writefln( m.name );
   }
}

Which would list the names of all modules. I was using the property to provide
useful feedback from a custom unit testing function. However, in DMD 2.042, it
seems that the ModuleInfo struct has been pared down to contain only the
unitTest property. Very inconvenient, if I may say so!

FWIW, I found that if I just sneak into src/druntime/import/object.di and add
" property string name();" to the ModuleInfo struct, everything works as before
-- the name property is defined in src/druntime/src/object_.d, so I'm curious
as to why it's excluded from the core.runtime-facing version.

Is there a particular reason for this? Is there some new part of the runtime
that I should be using to examine module names and unit tests?

...And am I going to explode anything by modifying druntime/import/object.di to
include the missing property?  :-P
Mar 23 2010
parent Walter Bright <newshound1 digitalmars.com> writes:
Trip Volpe wrote:
 FWIW, I found that if I just sneak into src/druntime/import/object.di and add
 " property string name();" to the ModuleInfo struct, everything works as
 before -- the name property is defined in src/druntime/src/object_.d, so I'm
 curious as to why it's excluded from the core.runtime-facing version.
 
 Is there a particular reason for this?
It's an oversight. Sorry.
Mar 23 2010