static import (v2.071.0)

Chris via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 11 08:25:25 PDT 2016


On Wednesday, 11 May 2016 at 14:28:00 UTC, Vladimir Panteleev 
wrote:
> On Wednesday, 11 May 2016 at 14:26:37 UTC, Vladimir Panteleev 
> wrote:
>
> To elaborate - this doesn't imply that the code of everything 
> in that module will always be placed in the executable. The 
> exact details depend on the implementation and configuration 
> (see e.g. GCC's -ffunction-sections).

I've updated the code now, but it takes some getting used to. Two 
questions:

1. Is it ok to have static imports locally or should they be on 
module level?

class Bla
{
   static import std.stdio;
   // ...
   std.stdio.writeln("import/export");
}

2. I still get a warning for calling a struct's member method. 
Why? E.g.

struct Bla
{
   public bool isBla(string str)
   {
     // ...
     return true;
   }
}

auto bla = Bla();

if (bla.isBla("string"))
{
   // ...
}

Bla.isBla is not visible from module xyz.

isBla is also defined somewhere else, but a member function of a 
locally allocated struct should not be confused with something 
like `std.uni.isBla`? Or should it?



More information about the Digitalmars-d-learn mailing list