www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19590] New: Impossible to iterate imported packages with


          Issue ID: 19590
           Summary: Impossible to iterate imported packages with
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de


module foo;

import std.stdio;
import std.string;

// This will indicate the existence of a package "std".
pragma(msg, __traits(allMembers, foo).stringof);

// This, however, will not indicate two modules "stdio" and "string", but
rather some other symbols, whose source is unclear.
pragma(msg, __traits(allMembers, std).stringof);

Furthermore, even if this worked it would not give an avenue to explore imports
by *other* packages, since, for instance, "std.stdio.std" is not a legitimate
symbol even if std.stdio was imported.

For this reason, I believe that allMembers should never return packages, only
complete modules. In other words, __traits(allMembers, foo) should return
"std.stdio" and "std.string".

Complication: what about renamed imports, such as import std.stdio : print =
writefln;? They don't show up either, and it's not clear how they *should* show
up. Make them appear as a member "print" of the current module, and it becomes
difficult to determine their source module.

A possible solution may be traits such as isImport and getDeclaredIdentifier.

Jan 15