Iterate module membres

crimaniak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 7 04:11:20 PST 2017


On Saturday, 7 January 2017 at 10:38:29 UTC, ketmar wrote:
> On Saturday, 7 January 2017 at 10:27:51 UTC, Nicholas Wilson 
> wrote:
>> Do you require a module statement per chance?
>
> it doesn't matter. if there is no explicit module declaration, 
> compiler will insert implicit one. from the code PoV, there is 
> no difference at all.
  Yes, module statement is no reason. package.d is reason. The 
same code in two files:

class foo{};
struct bar{};
pragma (msg, "allMembers of "~__MODULE__~" in "~__FILE__);
pragma(msg, __traits(allMembers, mixin(__MODULE__)));

Result:

allMembers of vcm.bll.event in source/vcm/bll/event/package.d
tuple()
allMembers of vcm.bll.event.test in source/vcm/bll/event/test.d
tuple("object", "vcm", "foo", "bar")

So allMembers gives empty tuple for module in package.d file. 
Please check it. As I understand documentation, package.d is 
ordinary module and special here is only file name used when 
module name is directory.
DMD 2.071.1. Is this a bug or documentation problem?



More information about the Digitalmars-d-learn mailing list