On Saturday, September 2, 2023 4:38:41 AM BST confused via Digitalmars-d-learn 
wrote:
> On Friday, 1 September 2023 at 13:45:05 UTC, evilrat wrote:
> > It is shadowing default implicit "import object;", here a
> > demonstration
> >
> > ```d
> > // this example shows default implicit import of "object" module
> > // compile this example:
> > //   ldc2 -c test.d
> > // output:
> > //   tuple("object", "core", "main", "thisModule")
> >
> > // just a random import
> > import core.stdc.stdio;
> >
> > void main() { }
> >
> > alias thisModule = __traits(parent, main);
> > pragma(msg,  __traits(allMembers, thisModule)); // has
> > implicitly imported 'object' module
> > ```
>
> Is there no way for the two to coexist?

If you put it into a package, then you could have your own object module
that then isn't at the top level - e.g. mypkg/object.d with

module mypkg.object;

but you can't have more than one module in your program with the same full
module name. So, in the case of the top-level module, object, you can only
declare your own if you replace the default one, which you might do in some
special situations, but it's not something that you would normally do, and
you can never have both the normal object module and your own in the same
program.

- Jonathan M Davis



  • I don't understa... confused via Digitalmars-d-learn
    • Re: I don't... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: I d... confused via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... confused via Digitalmars-d-learn
            • ... bachmeier via Digitalmars-d-learn
              • ... confused via Digitalmars-d-learn
                • ... bachmeier via Digitalmars-d-learn
            • ... evilrat via Digitalmars-d-learn
              • ... confused via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... confused via Digitalmars-d-learn
                • ... evilrat via Digitalmars-d-learn
                • ... rempas via Digitalmars-d-learn
            • ... ryuukk_ via Digitalmars-d-learn
              • ... confused via Digitalmars-d-learn
                • ... evilrat via Digitalmars-d-learn

Reply via email to